Hello,

I am trying to store data within a char in C. Different types of data will be used, for example, strings and integers.

I have tried the following code:

char rawdata[4] = {0xfe, 0x01, 0x99, 0x42};
unsigned int *test = (unsigned int*) rawdata;
printf("%u\r\n", *test);

However, it returns the integer 1117323774 (hex: 42 99 01 fe). The integer that it should return is 4261517634 (hex: fe 01 99 42).

What would be the best way of doing this without returning the input backwards?

Regards,
John.

How the data is interpreted depends on the operating system. MS-Windows and *nix are opposite -- *nix interprets them left to right and MS-Windows right-to-left. That's termed endianness (see wiki article here)