I’m coding a network game in C. I ‘ve written scores in a file. I also wanted to add the date of the day.
Here is the file’s structure : Date Name Score
and the code :
ScoreFile = fopen("scores.txt", "a");
fprintf(ScoreFile, "%s %d\n", Name, Score);
I’ve tried system(“date”) but it’s printed on stdout. I think that I can’t add the Date with fprintf.
Do you know a solution that permits to add Date in a file ? (maybe something from time.h ?)
thanks a lot !!
Consider using strftime to convert the time structure to string.
Example (from link above):
puts
Jul 9, 2011; 17:55:55\nins