C
copx
I want to read/write a specific binary data file format. The issue is
that the format uses 4 byte integer values and how do you read/write
those on a platform that has no native 4 byte integer data type?
Actually all platforms currently supported by my program have such a
type but I want to make the program more portable. My goal is to support
all platforms that have a native integer data type at least 4 byte wide.
Can I just use int_least32_t like this (remember I am trying to
read/write a 4 byte integer here):
reading:
...
int_least32_t foo = 0;
...
fread(&foo, 4, 1, in_file);
...
writing:
....
fwrite(&foo, 4, 1, out_file);
...
that the format uses 4 byte integer values and how do you read/write
those on a platform that has no native 4 byte integer data type?
Actually all platforms currently supported by my program have such a
type but I want to make the program more portable. My goal is to support
all platforms that have a native integer data type at least 4 byte wide.
Can I just use int_least32_t like this (remember I am trying to
read/write a 4 byte integer here):
reading:
...
int_least32_t foo = 0;
...
fread(&foo, 4, 1, in_file);
...
writing:
....
fwrite(&foo, 4, 1, out_file);
...