One approach could be to get them to specify the number of seats on the command line. I.e.
Code:
/* check a flight number entered */
if (argc != 3) {
printf("usage: %s train_number number_of_seats\n", argv[0]);
exit(1);
}
/* convert flight number to an integer */
train = atoi(argv[1]);
seat = atoi(argv[2]);
/* etc... */
Obviously if you want it to be interactive that's a little trickier. Ask the user to enter the new number of seats after this line:
Code:
printf("%d seats remaining on train %d\n",
seats, train);
And then write the user input number of seats to your file rather than the decremented one.
Hope that Helps,
Charlie
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock:
http://charlieharvey.org.uk