Hello guys
I've never dealt with files in C language.
I would like to know if the code I wrote is correct. It seems to work but I'm not sure about the syntax.
<code>
FILE *f1;
struct service {
char city[40];
char train_station[40];
};
struct service train_stop;
strcpy(train_stop.city, "1");
entree = fopen("list_cities", "a");
while(strcmp(train_stop.city,"ZZ") != 0)
{
printf("Enter a city (ZZ to end): ");
scanf("%s", train_stop.city);
if(strcmp(train_stop.city,"ZZ") != 0)
{
fprintf(entree, "%s\n", train_stop.city);
printf("Enter the corresponding train station: ");
scanf("%s", train_stop.train_station);
fprintf(entree, "%s\n", train_stop.train_station);
}
}
fclose(f1);
}
</code>