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 6:03

>>12

As a statement, that is illegal. a is an array of char and not an array of char*.

As a declaration, 'char a[x] = "hey"' is the same as 'char *a = "hey"'. No copy is involved, the variable is just a pointer to the string which is in the const data segment.

sizeof() is different, though. For the second, sizeof(a) is sizeof(char*) which is usually 4.

For the first, sizeof(a) is sizeof(char[3]), which is 3, because there are three elements.

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