In the pset3 Game of fifteen

What is the role of fprintf, fopen and other functions starting with f

And what is the function of

FILE *file = fopen("log.txt", "w"); fprintf(file, "%i", board[i][j]); fprintf(file, "|"); usleep(500000);


Many functions starting with f like fopen, fprintf, or fclose are related to "files". Files in that sense are also stdin, stdout, and stderr.

The code you mentioned is used to write some information to file "log.txt" (opened for "w"riting), writing a representation of the current game state to disk. That one is probably not meant to be changed in any way, and therefore can be used to test your programme's logic independently from your game representation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .