In this how-to, we are going to build a “Hello World” console application Visual C++.
Ok, let’s build our Hello World app!
After launching Visual Studio, we click on “File“, “New“, “Project“.
We then select the template for this new project, in this case “Visual C++” (1), the type of the project, in this case “Win32 Console Application” (2), the name and disk location of the project (3 and 4), and finally the solution name (5) which by default gets the same name as the project name but of course you can change it if you want. After all these are set, we click on the “OK” button (6).
Right after we click OK, we are presented with the ‘Win32 Application Wizard‘”. For this example, we just click on the “Finish” button.
After clicking on the “Finish” button we are ready to write code. The below screenshot illustrates the development environment:
As we want to perform an output operation, we need to add the <iostream> library to our application with the code line:
Also, we need to use the proper namespace (std) with the below code line:
using namespace std;
The last step is to add the code to be executed when our application runs:
The below command will display the “Hello World” message:
cout << “Hello World! This is a C++ program!”;
And the getchar(); command will pause the console window in order to let us see the output.
After adding the above code lines we Build our application from the “Build” menu – “Build Solution” function.
After our solution’s build operation succeeds, we can run our application by pressing F5 or by clicking on the debug button (play button sign). As we can see from the below screenshot, our program runs and successfully displays the “Hello World” message!
Learn more about interesting technology topics in our eBook: “Tech How To’s Vol. 1“
Reference: TechHowTos.com (http://www.techhowtos.com)
Rate this article:
Recommended eBooks on SQL Server: