Possible Duplicate:
How do you allow spaces to be entered using scanf?
How can I scan strings with spaces in them using scanf()?
New to C and I feel this should be very simple but for some reason I'm not seeing the clear answer.
Trying to write a name and address to a file but if I put 'FirstName LastName' only FirstName gets entered into the file. Same with address. Is there a way to accept the whole name with the space into the file?
struct person{
char name[20];
char address[50];
char telno[20];
} info;
fp=fopen("contacts","a")
printf("Enter Name : ");
scanf("%s",info.name);
printf("Enter Address : ");
scanf("%s",info.address);
fprintf(fp,"%20s %20s %20s",info.name,info.address,info.telno);
fclose(fp);
New to C so please excuse my ignorance. Thanks.