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

sizeof

Name: Anonymous 2009-04-26 9:56

I have a function that relies on the sizeof statement to get the size of a constant array of unsigned bytes. Everytime I use the function the sizeof statement returns 4 regardless of the size of my array.

Here's the code that doesn't seem to work. The array argument is defined as a const u8 array[].

u8  c;
   
for(c = 0;c <= sizeof(array);++c){
    //do something here
}

Name: Anonymous 2009-07-21 3:50

>>8
I lol'd.

>>21
C89 doesn't have that header, either, and not all compilers support C99.

>>25
sizeof(int) depends on the implementation, not on the architecture. Old Borland compilers (though I'm not sure if this has changed) have sizeof(int)==2. In fact, there doesn't need to be any relation between the sizes of integers and the sizes of pointers.

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