Friday, September 19, 2008

Running C++ programs in VS2008

I wanted to brush up my C++ skills, write link list/tree programs, however I my simple hello world program was not compiling in VS2008 -- It kept saying iostream.h file not found.

Here's how I got it running :

After starting a new Win32 project, in the wizard, I unselected "Use Precompiled Header".

Now the following code compiles and runs.

#include "stdafx.h"
#include <iostream>
using namespace std;

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



stdafx.h already includes stdio.h and tchar.h, so we can also move #include <iostream> to stdafx.h

No comments: