Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

HALP

Name: Anonymous 2007-02-10 18:58

char temp4[3];
unsigned long int FileStart;
FileStart = (temp4[3] << 24) | (temp4[2] << 16) | (temp4[1] << 8) | (temp4[0]);

This was supposed to take four bytes and turn them into a long int. How do I do this so that the << doesn't turn every byte other than the first one into 'FF'?

Name: Anonymous 2007-02-11 5:42

>>8

No. a[x] specifies x number of elements.
Access is from 0 to x-1. a[x] lvalues are defined as exactly the same as *(a + x * sizeof(a[0])), and therefore a[-1] accesses the memory location behind a[0].

This is undefined, because C is not a sissy language with bounds checking. a[3] appears to work but writing or reading from it is permitted to make your computer explode.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List