Results 1 to 5 of 5

Thread: Newbe help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Unhappy

    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)

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
    Code:
    using namespace std;
    somewhere. Here's your code again:
    Code:
    #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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    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!!!!!

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    How come it was working at home?
    Harry.

    "From one thing, know ten thousand things."

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width