C链表(文件)

C链表(文件),c,pointers,linked-list,C,Pointers,Linked List,问题:我需要调出文本文件中的信息,但是它会产生不同的输出。它表示不兼容的指针类型。当我检查文本文件时,编码的信息已正确保存。但是,当我尝试使用viewVoter功能查看文本文件中保存的数据时,它显示了不同的符号。。我只是编程领域的新手,任何反馈或回答都将不胜感激 #include<conio.h> #include<stdlib.h> #include<string.h> #include<stdio.h> struct Voter{

问题:我需要调出文本文件中的信息,但是它会产生不同的输出。它表示不兼容的指针类型。当我检查文本文件时,编码的信息已正确保存。但是,当我尝试使用viewVoter功能查看文本文件中保存的数据时,它显示了不同的符号。。我只是编程领域的新手,任何反馈或回答都将不胜感激

#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>

struct Voter{
       char VFname[25];
       char VMname[25];
       char VLname[25];
       char Course[25];
       short Vyearlevel;
       short RegNumber;
       struct Voter *next;
};

typedef struct Voter* Voters;

Voters top = NULL;

Voters Addvoter(){ 


          Voters newVoter = (Voters)malloc(sizeof(struct Voter)); 

             printf("\t\t|-----------------Voter----------------|\n");
             printf("\t\t|-----------Registration Form--------------|\n");
             printf("\t\t|-----------Add New Voter Detail-----------|\n"); 
             printf("|-----------TYPE THE INFORMATION BESIDE THE REQUIRED FIELD-----------|\n\n\n");

             printf("First Name:");  
             scanf("%s",newVoter->VFname); 

             printf("Middle Name:");  
             scanf("%s",newVoter->VMname);

             printf("Last Name:");
             scanf("%s",newVoter->VLname);

             printf("Course:");
             scanf("%s",newVoter->Course);

             printf("Yearlevel:");
             scanf("%i",&newVoter->Vyearlevel);

             printf("Registration Number:");
             scanf("%i",&newVoter->RegNumber);


FILE *List_Voter;

             List_Voter = fopen("Voters.txt","a+");

             fprintf(List_Voter,"%s\t%s\t%s\t%s\t%i\t%i\n",&newVoter->VFname,newVoter->VMname,newVoter->VLname,newVoter->Course,newVoter->Vyearlevel,newVoter->RegNumber);

             fclose(List_Voter);

             printf("Voter Successfully Registered!!\n");

             newVoter->next=NULL; 

             return newVoter;

             }

void viewVoter(void)
{

                    FILE *List_Voter;

                    List_Voter=fopen("Voters.txt","r");

                    Voters newVoter = (Voters)malloc(sizeof(struct Voter)); 

                    while(!feof(List_Voter)){

                    fscanf(List_Voter,"%s\t%s\t%s\t%s\t%i\t%i\n",&newVoter->VFname,&newVoter->VMname,
                    &newVoter->VLname,&newVoter->Course,&newVoter->Vyearlevel,&newVoter->RegNumber);

                    printf(List_Voter,"%s\t%s\t%s\t%s\t%i\t%i\n",&newVoter->VFname,&newVoter->VMname,newVoter->VLname,newVoter->Course,newVoter->Vyearlevel,
                    newVoter->RegNumber);

                    newVoter->next=NULL;

}
                    fclose(List_Voter);        
}

没有输入本身是不同的。和什么不同?此外,scanf和company非常糟糕,很自然地,您没有正确地使用它们。我建议改用fgets。请使用所有警告和调试信息进行编译,例如gcc-Wall-g,并学习如何使用调试器,例如gdbbtw。我使用dev c作为编译器。@user3477950我的意思是,当我保存信息时,比如说John Smith,它将正确地保存在文本文件中,但当我尝试提取信息时,它只是显示不同的信息symbols@user3526977你是说Dev-C++?那不是编译器。这是一个IDE。