this works but
after i enter street name
town the cursor jump to country
Code:
#include <stdio.h>#include <stdlib.h>
#include<windows.h>
/* Use of typedef in Structure */
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: ");
scanf(" %s",&myaddress2.local_street2);
printf("\n\n\nEnter Town: ");
scanf(" %s ",&myaddress2.town2);
printf("\n\n\nEnter City: ");
scanf(" %s",&myaddress2.city2);
printf("\n\n\nEnter Country: ");
scanf(" %s",&myaddress2.country2);
fscanf(ptr,"%s %s %s %s\n",&myaddress2.local_street2,&myaddress2.town2,&myaddress2.city2,&myaddress2.country2);
fprintf(ptr,"%s %s %s %s\n",&myaddress2.local_street2,&myaddress2.town2,&myaddress2.city2,&myaddress2.country2);
fclose(ptr);
printf("data added");
return 0;
}
i added space here
Code:
scanf(" %s ",&myaddress2.town2);
but still same thing happens