Adding structure data in txt file not working
Hello friends,
i am trying to add structure data to txt file but it gives errors
Code:
#include <stdio.h>#include <stdlib.h>
#include<windows.h>
/* Use of typedef in Structure */
typedef struct home_address2{
char local_street2[100];
char town2[60];
char city2[60];
char country2[60];
}myaddress2;
int main(){
FILE *ptr;
ptr=fopen("address.txt","a");
printf("\t\t\t\xB2\xB2\xB2\ ADD RECORD \xB2\xB2\xB2\xB2");
printf("\n\n\nEnter Street Address \t\t\Town\t\t\City\t\tCountry :");
scanf("%s %s %s %s",&myaddress2.local_street2,&myaddress2.town2,&myaddress2.city2,&myaddress2.country2);
while(fscanf(ptr,"%s %s %s %s\n",&myaddress2.local_street2,&myaddress2.town2,&myaddress2.city2,&myaddress2.country2)!=EOF)
{
printf("data added");
}
fclose(ptr);
return 0;
}