I have this problem with binary files. I cant access the file properly. Here is a portion of my program:-
main(){
char name[1000];
int x,num;
FILE *fptr;
fptr=fopen("name.txt","w");
printf("Enter number of names: ");
scanf("%d", &num);
for(x=0;x<num;x++){
printf("Enter name: ");
scanf("%s", name);
fwrite(&name, sizeof(name),1,fptr);
}
fclose(fptr);
fptr=fopen("name.txt", "r");
while(fgets(name,1,fptr)!=NULL){
fscanf(fptr,"%s",&name);
...
...
}
}
the problem is that i cant read more than 1 name in the list
If I save more than 1 name in the .txt file, then when i try to read it, there will be some error.Please HELP. I'm a beginner.