output unsigned 64bit value using ofstream

I use fc15 32-bit gcc-4.6.0 and use ofstream to write to my file but some times (I think when the number is too big) it write the unsigned 64-bit value as a negative number.

long long values;
ofstream myofs;

example :
content of file :
#1 #2 #3

how can I sure that this is the problem and fix it?

thanks in advance

A long long is not an unsigned value by default, so the stream will interpret it as such. Realize that the value written to the file is based on the type you give it, not the underlying bits or anything.
SO, I must convert long long to string ,for example by sprintf , and then give it to ofstream to write it in the file?

Is this true or I should use other method?
Last edited on
Try using unsigned long long
or std::uint64_t from <cstdint>.
Topic archived. No new replies allowed.