Testing my first "Hello World" in VSC++

Started by
12 comments, last by Conner McCloud 18 years, 5 months ago
Hi! I'm as fresh I can be at programming, so well. I started with a tutorial and tested the Hello World code, but when I was going to debug it in "Visual Studio C++ 2003 .Net" it got an error, that I dont remember what it said... Anyway, I cleaned up my "Visual Studio Project" folder and restarted with a new .cpp project, and tried again. But now I cant press the debug button somehow, its inactive. What should I do? Hope somebody can push this noobie in the right direction, so I can deal with the rest. Thank you! // PriMo Here is the code by the way(directly copied from the tutorial, so there should be no errors):
#include <iostream>

using namespace std;

int main()
{
  cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
  cin.get();

  return 1;
}
Advertisement
please somebody help.
I don't know how to use VSC++ .net anyway, try compiling the program and see if the debug turns on.
You have not provided any information that could be used to help you.

CM
Press F5, if it ask if you want to compile answer yes.

Lizard
Nothing happens when I press F5, just because its inactive.

If you can not tell me how to fix this problem, then is there like a special setup you got to do before starting programming?

Ok, now I tried with starting a new "win32 console project" instead of a .ccp file.
So now i can debug but this is the error that come up:

c:\Documents and Settings\PriMo\My Documents\Visual Studio Projects\hello\hello.cpp(12): fatal error C1010: unexpected end of file while looking for precompiled header directive

Anybody have a clue?
If you are just trying to do a 'Hello World' program, you might want to start by using a Win32 Console project and then add your hello.cpp file to it. The error you are getting looks like it is related to some resource file dependencies or stdfx.h (Windows specific).

If you are still having trouble, I'll send you a simple workspace if you like.

Will
#include "stdafx.h"

Or something like that (not sure I got the name exactly right). Either this, or you could turn off precompiled headers.

This is usually #included automatically when you create a new project.
Quote:Original post by PriMo222
c:\Documents and Settings\PriMo\My Documents\Visual Studio Projects\hello\hello.cpp(12): fatal error C1010: unexpected end of file while looking for precompiled header directive

Anybody have a clue?

Now we're getting somewhere.

If you have your project setup to use precompiled headers [which is the default state], the first line of every source file has to be #include "stdafx.h". Just add that line and see if it takes care of the problem. If not, you can turn off precompiled headers by going to Project->Properties->C/C++->Precompiled Headers.

CM
File->New->Project
Select Visual C++ Projects on the left, Win32 Console Project on the right.
Type a project name, choose a directory, and hit OK.

A wizard will come up. DO NOT PRESS FINISH. On the left, click Application Settings. Check the Empty Project checkbox. Now press Finish.

Main menu: Project->Add New Item.

On the right, click "C++ File (.cpp)". Type the name of your new file and click Open.

Now type in your code. F7 compiles, F5 compiles if needed and then runs in debugger (recommended), Ctrl-F5 compiles if needed and then runs without debugger (a little faster).



~BenDilts( void );

This topic is closed to new replies.

Advertisement