First time running something

I downloaded Microsoft Visual C++ 2010 Express today and tried running the HelloWorld program in the tutorial's first page. I press F5 to start debugging it, but there's build errors.

1
2
3
4
5
6
7
8
9
10
11
// pj2012_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	cout << "Hello World!";
	return 0;
}


1
2
3
1
1>  pj2012_1.cpp
1>c:\users\tannguyen\documents\visual studio 2010\projects\pj2012_1\pj2012_1\pj2012_1.cpp(9): error C2065: 'cout' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


cout has a red underline and std has a red underline.
You're missing the #include <iostream> header.

Add it under "#include "stdafx.h"
That looks so complicated lol.
i mean the 7th line.

im using Code::Blocks compiler and the same code would look like this:

1
2
3
4
5
6
7
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World!";
cin.get();
}
Thank you. I ended up with a different problem.

1
2
3
4
5
6
7
'pj2012_1.exe': Loaded 'C:\Users\emwat\Documents\Visual Studio 2010\Projects\pj2012_1\Debug\pj2012_1.exe', Symbols loaded.
'pj2012_1.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'pj2012_1.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'pj2012_1.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'pj2012_1.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'pj2012_1.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[692] pj2012_1.exe: Native' has exited with code 0 (0x0).
I might switch to Code::Blocks compiler soon then. But at least my problem's working now. I added cin.get(); and I see the "Hello World!"
I always get those messages in VC++, hold CTRL and press F5 to run without debug, you program should work fine!
Topic archived. No new replies allowed.