Go Down

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

Desperado

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...

//pseudocode...
int cracker[0];

falutyClass{
public:
int *ptr;
}

faultyClass myClass;

setup{
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?

RuggedCircuits

Err....it is an error :)

Declaring
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

Desperado


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!

Arduino
via Egeo 16
Torino, 10131
Italy