[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
VisualCpp2005HelloWorld

(Visual C++ 2005) Hello World

How to make a Hello World program in Visual C++ 2005:

First you need to create a project
  • Click 'File | New Project'. The 'New Project' window appears
  • Choose the Project Type 'Visual C++ | Win32', then the Template 'Visual Studio Installed Templates | Win32 Console Application'
  • Type an appropriate name at 'Name', for example 'HelloWorld'. While typing this, the Solution Name can be seen to get the same name, which is okay.
  • You can optionally change the location of the project
  • You can optionally uncheck the CheckBox 'Create directory for solution', but [[I | Bilderbikkel]] prefer it checked.
  • Press OK to start the Win32 Application Wizard
In the Win32 Application Wizard
  • Click Next in the first screen. You can also click 'Finish' but this can be done if the settings in 'Next' are already set correctly.
  • In the next menu screen 'Application Settings', set the Application Type to 'Console Application' .
  • Uncheck 'Empty Project'
  • Check or uncheck 'Precompiled Header'. In this example, I keep it checked.
  • Click Finish to be taken to the Code Editor.
In the code editor, the code will look like this:

// HelloWorld.cpp : Defines the entry point for the console application.
//
  1. include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[]) { return 0; }


Change this to
// HelloWorld.cpp : Defines the entry point for the console application.
//
  1. include "stdafx.h"
  2. include <iostream>
int _tmain(int argc, _TCHAR* argv[]) { std::cout << "Hello World" << std::endl; return 0; }


Press CTRL-F5. Done!

Note

The main function above is not standard. The standard-conform code would be:
// HelloWorld.cpp : Defines the entry point for the console application.
//
  1. include "stdafx.h"
  2. include <iostream>
int main() { std::cout << "Hello World" << std::endl; }


Prefer to post this code on forums.

'Hello World' links



last edited (March 3, 2007) by bilderbikkel, Number of views: 2177, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.