El Jueves 22 Enero 1998 a las 17:06, Christian Felde le dijo a All:
CF> This program works, but it seams like when I give more the 3 char's in
CF> to array 2, I get this: "Segmentation fault (core dumped)"
Arrays are declared like this:
char array[ARRAY_SIZE]
but, when accesing the array's elements keep in mind that the first index is
0, so a two element array (e.g.
char array[2]
) would have these two elements: array[0] and array[1], array[2] would be a
third element, and out of bounds considering the declared array.
CF> cout << "Enter array 1: ";
CF> cin >> array[1];
cin >> array[0];
CF> cout << "Enter array 2: ";
cin >> array[1];
Now that's better! :)
Eric Londaits
wocky@usa.net
--- GoldED/2 2.50 UNREG
---------------
* Origin: Rocketman Point (4:900/265)
|