I tried to do something simple to write some detail that I got from user to a txt file and it works but I want them to be at the same line and for some reason the last one that I write is in the next line.
printf("\nPassengers Details:\n===================\n");
printf("Please Enter Passenger`s Passport-->:");
scanf("%d", &p1.passportnum);
getchar();
printf("\nPlease Enter Passenger`s First NAME-->:");
fgets(p1.firstname, SIZE, stdin);
printf("\nPlease Enter Passenger`s Last NAME-->:");
fgets(p1.lastname, SIZE, stdin);
fpassengers = fopen("passengers.txt", "w");
fprintf(fpassengers,"%d %s %s", p1.passportnum, p1.firstname, p1.lastname);
fclose(fpassengers);
In the file it writes the first 2 at the same line and the last name
in the next line .
How do I make them be at same line??