PDA

View Full Version : compile problems...


nnyexoeight000
14-10-2003, 01:04 AM
I downloaded devC++ free compiler.

Copied the code from Tutorial 7 in this forum.

Compiled and Ran.

but it failed, lots of errors.

...great. What went wrong?

Grif
14-10-2003, 01:33 AM
Well, if you could tell us what the errors were, maybe then we could give you a hand, otherwise its like looking for a fly on an elephants ass (no offence man)
Cheers ;)

nnyexoeight000
14-10-2003, 02:12 AM
Well, ok... I thought you would have an answere that had to do with me missing a .h file or something.

The example code was extremely simple and part of a tutorial, so i figured it would work right off the bat.

Here are the problems I got:
test01.cpp:9: `array' undeclared
(first use this function)
test01.cpp:9: (Each undeclared
identifier is reported only once for each function it appears in.)
test01.cpp:12: `cout' undeclared
(first use this function)

Execution terminated

here is the code from the tutorial:

#include iostream.h

int main ()
{
int an_int = 3;
int* a_pointer = &an_int;
int an_array[3];

array[0] = 1; //Ok so we have zero offset so this is the first element
array[1] = 2; //one offset this is the second element
array[2] = 3; //finally we have two offsets or the third elment
cout << array[0]; //here we are accessing the first element again
cout << "\n"; //hey look a string!
cout << array[1]; //here we access the second element
cout << "\n";
cout << array[2]; //and the third
cout << "\n";
cout << a_pointer[0]; //and here we use the array operator on GASP a pointer!

return 0;
}


And im using Dev C++ tutorial from www.bloodshed.com I believe.

help me make this work... please...
thx.

MadMechwarrior
14-10-2003, 02:19 AM
you gotta change 'array' to 'an_array' since the array variable never gets declared and your either missing a library or an include for the cout thing, thats a basic C function which I dunno what the include is by heart. Look it up, should take about 30 seconds to find

Grif
14-10-2003, 02:27 AM
Yeah, the MadMech is right about the array. The easiest way to fix this would be to change int an_array[3]; to int array[3]; since everywhere else you use array. And second, #include <iostream.h> you are missing <>.
And i suggest you use
#include <iostream>
using namespace std;

iostream.h is an old header and have been deprecated.
The rest seems to look Ok.
Cheers ;)

nnyexoeight000
14-10-2003, 03:37 AM
those problems should be addressed in the tutorials... oh well... too late now, thanks for your help tho.