Go Down

Topic: Pointers to Array.. (Please this post to software) (Read 1 time) previous topic - next topic


Sep 12, 2010, 10:54 pm Last Edit: Sep 12, 2010, 11:28 pm by Desperado Reason: 1
It seems like there is some error in pointing to array with only one item in it...

int cracker[0];

int *ptr;

faultyClass myClass;

myClass.ptr = &cracker[0];

The exact same code works if i change int cracker[0] to int cracker[1].
I do not get any errors from the compiler or so... It just won't work.
Is this an error or am I just plain stupid?


Err....it is an error :)

Code: [Select]
int cracker[0]; says you want an array with 0 elements. You want an array with 1 element, so replace 0 with 1.

The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131