In this tip, we are going to build a “Hello World” console application in Visual C++.
If you don’t already have Visual Studio, the you can download Visual Studio Community Edition which is free.
Building the App in Visual Studio
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:
#include <iostream>
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!
Recommended course: “Introduction to Computer Programming for Beginners”
Enroll to our course on Udemy, titled “Introduction to Computer Programming for Beginners” and get the help you need for getting started with C++, C, Python, SQL, Java, C# and the main phases of the Software Development Lifecycle.
Recommended Online Courses:
- SQL Server 2022: What’s New – New and Enhanced Features
- Introduction to Azure Database for MySQL
- Working with Python on Windows and SQL Server Databases
- Boost SQL Server Database Performance with In-Memory OLTP
- Introduction to Azure SQL Database for Beginners
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- Introduction to Computer Programming for Beginners
- .NET Programming for Beginners – Windows Forms with C#
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- A Guide on How to Start and Monetize a Successful Blog
- Data Management for Beginners – Main Principles
Read Also:
- Welcome to {essentialDevTips.com}!
- Understanding Dependency Injection in C#
- How to Write a “Hello World” App in C#
- How to Rebuild All Indexes Online for a SQL Server Database
- Benefits of Primary Keys in Database Tables
- Main Data Structures in Python
- How to Fix: Slow WiFi Internet Connection on Windows 10 Laptop
- SyntaxError: invalid syntax when using IF in Python – How to Resolve it
- Using Dynamic Memory Allocation in Java
Reference: {essentialDevTips.com} (http://www.essentialdevtips.com/)
© essentialDevTips.com
Rate this article:
Artemakis Artemiou is a seasoned Senior Database and AI/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.