I'm writing an fuction and I got a problem, the scanf function cant read spacebar " ", how can I solve it?
void add()
{
char choose2;
FILE *fp;
struct booking book;
system("cls");
fp=fopen("hotelbooking.txt","a");
if(fp == NULL)
{
printf("There are no data file!");
}
else
{
printf("Add New Hotel Booking Record(s)\n");
printf(" Name of Traveller: \n");
scanf("%s",book.travellername);
fprintf(fp,"\n%s",book.travellername);
printf(" Destination: ");
scanf("%s",book.destination);
fprintf(fp,"\n%s",book.destination);
fclose(fp);
}
}
In the tervellername part, If I want to enter e.g. "Jason George", How can I scan the space bar between the name?
I'm using the structure below:
struct booking
{
char travellername[20];
char destination[20];
}book;