char* != &char[0] ?

Started by Kochise, April 18, 2013, 04:26:00 PM

Previous topic - Next topic

Kochise

PellesC hangs on this :

unsigned char *pointer;
unsigned char array[20];
pointer = &array[];

error #2140: "expected 'unsigned char *' but found 'unsigned char (*)[]'."

Kochise

TimoVJL

use pointer = &array[0];orpointer = array;
May the source be with you

Kochise

Tried the first (&array[0]) with no luck.

Will try the second. Visual C++ 6 and Express 2008/2010 are just fine with the first. I just wanted to add PellesC compatibility, but it seams to be very delicate upon syntax.

Kochise

TimoVJL

Quote from: Kochise on April 18, 2013, 05:16:31 PM
Tried the first (&array[0]) with no luck.
In my tests (v5 v7), this works:int main(int argc, char **argv)
{
unsigned char *pointer;
unsigned char array[20];
//pointer = &array[];
pointer = &array[0];
pointer = array;
return 0;
}
May the source be with you