|
-
Sep 17th, 2008, 12:33 AM
#1
Thread Starter
Addicted Member
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.
-
Sep 17th, 2008, 05:20 AM
#2
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:
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
printf( "Hello World!" );
cout<<"hello world!";
return 0;
}
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:
std::cout << "hello world";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|