Sign in to follow this  
PriMo222

Testing my first "Hello World" in VSC++

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 );

Share this post


Link to post
Share on other sites
Quote:
Original post by BeanDog
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.

At this point, there's a setting to not use precompiled headers, but its greyed out so you can't turn it off. Annoys me to no end.

CM

Share this post


Link to post
Share on other sites
Quote:
Original post by Eriond
If you check empty project there won't be any precompiled headers.

Well I'll be damned, you're right. I just sort of assumed 'empty project' didn't change anything except what files it generates automatically.

CM

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this