PDA

Click to See Complete Forum and Search --> : Newbe help


joey o.
Sep 19th, 2000, 12:45 PM
OK,
I wish there was a smiley that had tears! Can someone help me? I give up. I've installed and uninstalled VC++6 and MSDN 3 times so far and still I can't run this c++ code on my WinNT machine in work. It works at home (Win98) but gives me these errors on the following code:

Here's the code:

#include <iostream>
int main(void)
{
cout << "Does this work?"
<< endl << endl;
return 0;
}


Here's the errors:

--------------------Configuration: NewOne - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\Apps\Microsoft Visual Studio\MyProjects\NewOne\Cpp1.cpp(5) : error C2065: 'cout' : undeclared identifier

D:\Apps\Microsoft Visual Studio\MyProjects\NewOne\Cpp1.cpp(5) : error C2297: '<<' : illegal, right operand has type 'char [16]'

D:\Apps\Microsoft Visual Studio\MyProjects\NewOne\Cpp1.cpp(6) : error C2143: syntax error : missing ';' before '<<'

Error executing cl.exe.

NewOne.exe - 3 error(s), 0 warning(s)

parksie
Sep 19th, 2000, 01:17 PM
It's not a bug, it's a feature. Seriously.

Since you're using the Standard C++ Library (the headers with no extension), you must use

using namespace std;

somewhere. Here's your code again:

#include <iostream>

using namespace std;

int main() {
cout << "Does this work?" << endl << endl;
return 0;
}

Alternatively, you can just put std:: in front of cout, or anything else related to the Standard C++ Library.

Sep 19th, 2000, 01:19 PM
Damn, i was reading the thread and there were no replies, and i thought, YA, I CAN ANSWER THIS ONE AND FINALLY HELP SOME ONE!!!!!!! Then i press reply and theres an answer at the bottom, just a few seconds to late!!!!!

HarryW
Sep 19th, 2000, 09:41 PM
How come it was working at home?

joey o.
Sep 20th, 2000, 12:44 PM
I think because of version of library. At home I used my MSDN but at work I downloaded their's. Someone else told me older versions defaulted the headers to like <iostream.h> from <iostream> which also makes it work on my work machine. I upgraded the VC++ to version6 at home. Maybe It kept hold of that stuff???
Either way - Thanks for all the help guys. I'll lic this stuff eventually and maybe someday offer help to others.

Joey O.