programmers ... very basic question about file input/output

purbeast0

No Lifer
Sep 13, 2001
53,505
6,345
126
this is very simple.

i am taking a clock count on the computer and getting a value in clock_t type.

however I want to write it to a file using fwrite() and i can't just write it in clock_t type because it takes void * as its type.

how can i get this clock_t type to work with the fwrite function? i know its basic but i can't remember lol, thanks!
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
fwrite simply spits the contents of a buffer to the file, so use fprintf and the appropriate format specifier for the clock_t type. You can use that used for floats, etc. like this:

fprintf(SOMEFILE, "Clock: %f", clockType);

Oh, and yes, wrong forum.