NO

Author Topic: char* != &char[0] ?  (Read 3499 times)

Kochise

  • Guest
char* != &char[0] ?
« on: April 18, 2013, 04:26:00 PM »
PellesC hangs on this :

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

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

Kochise

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2155
Re: char* != &char[0] ?
« Reply #1 on: April 18, 2013, 05:05:10 PM »
use
Code: [Select]
pointer = &array[0];or
Code: [Select]
pointer = array;
May the source be with you

Kochise

  • Guest
Re: char* != &char[0] ?
« Reply #2 on: April 18, 2013, 05:16:31 PM »
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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2155
Re: char* != &char[0] ?
« Reply #3 on: April 18, 2013, 05:34:26 PM »
Tried the first (&array[0]) with no luck.
In my tests (v5 v7), this works:
Code: [Select]
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