Trouble Using C++ Program

Hello! Thank you for taking the time. ^_^

I have Microsoft Visual C++ 2008 Express Edition and I attempted to use it as a regular C++ compiler, but that doesn't work. I attempted " Hello World", but it doesn't work. Is there some different way to use this than a basic C++ compiler?

If you can direct me to a link where it'll explain or you can explain yourself I would greatly appreciate it.
Last edited on
Well... VC++ is a regular C++ compiler, so my guess is that you're doing it wrong. And you'll need to learn to use a less ambiguous language. There's many meanings for "doesn't work".
First I'll need to see your code, then I'll also need to see what steps you take to create a new project, compile, and execute.
I suspect your problem is the choice of project type when you start.
MS VC++ will (probably) try and direct you down the path of a Windows .Net project, with default forms, etc.
I imagine you are wanting to build a basic 'console' application.
Try selecting Win32, then Win32 Console Application from the project types dialog (this is based on VC++ 2005, but i imagine it's very similar).

I appreciate the feedback.

The code I used was:
//====================================================
#include <iostream.h>

main()
{
cout << "Hello World!";
return 0;
}

//================================================
and I opened the console application. When I try to compile I get the error message:

------ Build started: Project: Lidiya, Configuration: Debug Win32 ------
Compiling...
Lidiya.cpp
.\Lidiya.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Lidiya\Lidiya\Debug\BuildLog.htm"
Lidiya - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Delete all files in the project except the one that contains your code.
Then go to Project Options->C/C++->Precompiled Headers->Create/Use Precompiled Header: Not Using Precompiled Headers.

Next time you create a new project, turn on the empty project checkbox.

Oh, and "iostream.h" is deprecated. Now we use "iostream".
How do I create the empty project checkbox. Can you walk me through step by step? All I know is how to use a really old C++ compiler I am currently learning in HS.
Before compiling the compiler looks for the stdafx.h header file in the source files either you have to disable it in the project properties or you have add that headerfile to your project.

If you create an win32 project or some other the tool will automatically generates the stdafx.h headerfile.
I use VC++ and to get a "blank" project you need to select a Win32 Console Project. When everything is done loading right click on the solution explorer and go down to C++/Precompiled Headers Properties like Helios said. Then remove the headers (stdfx and whatever the other is),

To remove the headers, select them from the solution explorer and right click, delete. Just remove them not delete them.
Then you can start programming.

Dev-C++ is a free compiler that avoids a lot of that project business. Its much easier to use but it is less elegant than VC++.

To use Dev-C++:
Open it and create a new source file. Then start coding and compile your project.

If you don't understand those directions, then just ask for more clarification.

Btw, Your code doesn't declare "cout" as a command. Just add the line
'using std::cout;'
somewhere above your 'main' function. (I usually add it below the #include directives)
Last edited on
Topic archived. No new replies allowed.