Results 1 to 2 of 2

Thread: c2065 day 1 error

  1. #1

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    c2065 day 1 error

    I searched the forum but I didn't find anything even remotely close to the simplicity of my problem...

    I don't need help with homework, have a big project due, or have a reason to rely on C++... yet. I just have one simple question about this damn C2065 error claiming I have an undeclared identifier. I did nothing but write one line of code to begin a hello world program and I am instantly hit with this identifier problem at every turn. It is very disheartening. I have done some research but none of the suggestions about how to fix the MSVC++ complier help.

    How come the following code:
    Code:
    #include "stdafx.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	printf( "Hello World!" );
    	cout<<"hello world!";
    
    	return 0;
    }
    Returns a damn error. This is getting quite annoying. I always considered myself pretty quick at catching on and then I spent an hour dealing with this.
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: c2065 day 1 error

    I take it that 'cout' is what it is complaining about?
    In order to use cout you'll have to include the iostream library:

    C++ Code:
    1. #include "stdafx.h"
    2. #include <iostream>
    3.  
    4. using namespace std;
    5.  
    6. int _tmain(int argc, _TCHAR* argv[])
    7. {
    8.     printf( "Hello World!" );
    9.     cout<<"hello world!";
    10.     return 0;
    11. }
    Since cout resides within the std namespace, I've specified "using namespace std" at the top, or else one would've had to specify the full name for cout:
    C++ Code:
    1. std::cout << "hello world";
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

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