Writing integer to file

03 Nov 2012

Hi all!

Hopefully a very simple question: is there a way to write an integer to a file? Strings are fine using fprintf.

Thanks in advance!

03 Nov 2012

Figured it out!

This is a great reference: http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/

Code looks something like this:

    fprintf(fp,"\r\n%i,", (int)Samples);     // write arbitrary integer to file
    fprintf(fp,"\r\n%f,", (float)Offset);     // write arbitrary float to file
    fprintf(fp,"\r\n%g,", (float)Offset);     // write arbitrary float to file in shortest form