Adding Date in a file - C -



Adding Date in a file - C -

i'm coding network game in c. 've written scores in file. wanted add together date of day. here file's construction : date name score , code :

scorefile = fopen("scores.txt", "a"); fprintf(scorefile, "%s %d\n", name, score);

i've tried system("date") it's printed on stdout. think can't add together date fprintf.

do know solution permits add together date in file ? (maybe time.h ?)

thanks lot !!

consider using strftime convert time construction string.

example (from link above):

#include <time.h> // ... char s[30]; size_t i; struct tm tim; time_t now; = time(null); tim = *(localtime(&now)); = strftime(s,30,"%b %d, %y; %h:%m:%s\n",&tim);

puts jul 9, 2011; 17:55:55\n in s

c file date file-io time.h

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -