T
TomServo
I am writing code that needs to run on a variety of Unix systems. I am
calling the statvfs and statfs system calls and I need to to convert some of
the integers returned to character strings. Normally I would do this using
sprintf as so:
sprintf(&buffer, "%lu", integer);
The problem is that I will not know if the integer values I am converting
are long or long long. I also do not know if the compilers being used will
support long long ints. So is there any way to convert a unknown integer to
a string without specifying what kind of integer?
Will itoa() work on a long long? If it doesn't, are there any calls like it
that will work on any int passed to it?
To reiterate what I need to do, here is some pseudo code:
struct statfs fsstruct;
statfs("/", &fsstruct);
// Take fsstruct.f_blocks value which is an int of unknown length and change
it to a string
// fsstruct.f_blocks could be a short int, long int, long long int, etc
// I also have no idea if long longs are supported
Am I making this harder than it is?
Thanks
calling the statvfs and statfs system calls and I need to to convert some of
the integers returned to character strings. Normally I would do this using
sprintf as so:
sprintf(&buffer, "%lu", integer);
The problem is that I will not know if the integer values I am converting
are long or long long. I also do not know if the compilers being used will
support long long ints. So is there any way to convert a unknown integer to
a string without specifying what kind of integer?
Will itoa() work on a long long? If it doesn't, are there any calls like it
that will work on any int passed to it?
To reiterate what I need to do, here is some pseudo code:
struct statfs fsstruct;
statfs("/", &fsstruct);
// Take fsstruct.f_blocks value which is an int of unknown length and change
it to a string
// fsstruct.f_blocks could be a short int, long int, long long int, etc
// I also have no idea if long longs are supported
Am I making this harder than it is?
Thanks