I want to read sizeof(int) bytes from a char* array.
sizeof(int)
char*
a) In what scenario\'s do we need to worry if endianness needs to be checked?
Why read when you can just compare?
bool AreEqual(int i, char *data) { return memcmp(&i, data, sizeof(int)) == 0; }
If you are worrying about endianness when you need to convert all of integers to some invariant form. htonl and ntohl are good examples.