Pages: [1]   Go Down
Author Topic: Pointers to Array.. (Please this post to software)  (Read 723 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino blox
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: September 12, 2010, 04:28:33 pm by Desperado » Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Err....it is an error smiley

Declaring
Code:
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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino blox
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks....
Logged

Pages: [1]   Go Up
Jump to: