C/C++ tutorial: Hello world

This tutorial helps you get started with C/C++. It explains what you need to write your first C/C++ program. It starts with the basics: you will learn where you can find and download the tools needed, how to install these tools and it will take you all the way to building and runing your code. If you have never written a C/C++ program before this is the place to start. We have created this article, so you can get started with C/C++, and move on to our sms examples. If you are already familiar with C/C++, you can jump directly to one of the following SMS projects.

C/C++ sms examples:

C/Cpp send sms with the HTTP rest api (code sample)
C/Cpp send multiple sms with the HTTP rest api (code sample)
C/Cpp schedule sms with the HTTP rest api (code sample)
C/Cpp receive sms with the HTTP rest api (code sample)
C/Cpp delete sms with the HTTP rest api (code sample)
Download the latest C/C++ sms api library from Github

What is C/C++

C/C++ is a programming language. It is similar to a natural language, like English. It is used to talk to a computer. The major difference between a natural language and a programming language is that, programming languages have a more rigorous structure, to help the computer understand it better.

What is Visual Studio

Visual studio is a tool to write a C/C++ program. Visual studio allows you to type in text using the C/C++ language, and it makes it possible for you to tell the computer, to read the text and execute the instructions. We use the term "Run" to tell computer to execute the instructions.

What is a C/C++ Hello world program

The C/C++ hello world program is the most simple program you can write. It simply prints out the sententce: Hello world on the computer screen. The Hello World program is the first program developers write in any programming language.

How to write your first program in C / C++

To write your first program in C / C++:

  1. Check prerequisites
  2. Setup Visual Studio
  3. Create a new project in Visual Studio
  4. Select C++ Console Application
  5. Name your project
  6. Write Hello World program in C / C++
  7. Run your C / C++ Hello World program
  8. Check the output


Here is what you need to get started. To write your first computer program in C/C++, you need a Windows computer, the Visual Studio programming environment and example code presented below.

  • Windows 10 computer
  • Microsoft Visual Studio Community Edition
  • Ozeki Hello World example project

Download Visual Studio

Microsoft Visual Studio Community Edition

In this video tutorial you will find how to download the Visual Studio Community Edition installer. You may download the installer from the following URL: https://visualstudio.microsoft.com/downloads/. On this page you will see different version of Visual Studio available for download. Follow the instructions in this short video to download the installer on to your computer.

Install Visual Studio

To write your first C/C++ program, you need to install Visual Studio. The following video shows you how this installation can be done. This video includes a specifically configured installation of Microsoft Visual Studio Community edition. It contains all of the settings and steps in order for you to successfully set up a C/C++ coding enviroment.

Create your first visual studio project

This short video tutorial shows you how to create a C/C++ project using Visual Studio. You will learn how to select the correct language (C/C++) as well as the project type. You will also find out how to select a path, a name, and a target framework for your newly created project. Once you have applied all the necessary settings, the C/C++ coding enviroment will launch inside of Visual Studio.

Create a new project in Visual Studio

First, open Visual Studio, which you have just installed. You will be then greeted by a welcome screen. This screen lets you create a new project or open previous ones. Under the "Get Started" column on the right, click on Create a new project (Figure 1). This will forward you to the next page where you can configure the settings of your project.

create new project
Figure 1 - Create new project

Chosse C++ Console Application

To create a C++ Console Application, you first need to typ "cpp" into the search bar on the top. The results will return Console APP as on of the options (Figure 2). Select this option by clicking on it. Click on the Next when you selected it to continue. This will bring you to another page where you can name your project.

console application
Figure 2 - Choose C++ Console Application

Name your project

After specifying your project as a Console App, you will be asked to give it a name. Under the text that reads "Project name" you will find a textbox (Figure 3). Enter your desired name into this textbox to name your project. Click on the Create button on the bottom right when you are done to create your project.

project name
Figure 3 - Write the project name

Write your 'hello world' program in C/C++

The first program you write in any programming language is the 'Hello world' program. The sole aim of this program is to print the term 'Hello world' to the computer screen. In this example the program consists of two lines of code: The first line: std::cout << ""; prints the text.

#include <iostream>

int main()
    std::cout << "Hello World!\n";

Enter the code

In this video we enter the "Hello World!" code by typing it in Visual Studio' text editor.

Run the C/C++ 'hello world' program

To run the hello world program, you need to click on the green Start button in the Visual Studio toolbar. You may also use the F5 key to run your program. Note that when you press F5, visual studio will first save your newly written file, then it will copmile it to an executable code, and then it will run it on your computer.

Run the program

You can run your newly written C/C++ program using Visual Studio. Find the Local Windows Debugger button with a green arrow next to it in the toolbar on the top (Figure 4). Click on this button to execute your code. This will bring up the Visual Studio Debug Console, where you can see the results of your program.

run the program
Figure 4 - Run the program

Hello World!

After you successfully ran your code, the Visual Studio Debug Console will pop up in a new window. Inside the debug console, you will see the "Hello World" message displayed (Figure 5). Press any key on your keyboard to close this console.

Figure 5 - Hello World!

What happens if I make a mistake in C/C++

If you make a mistake, when you write your instructions in C/C++, you will get a Syntax error. The computer will highlight the line with error in red, and it will tell you why didn't it understand the instructions. To correct the mistake you need to go back to the text editor and modify the program. Programs say they "fix the error" when they correct mistakes.

What is syntax error in C/C++?

Syntax error means I don't understand. If you talk to somebody in English and he does not understand what you say, he will reply with "I don't understand". If you talk to a computer in C/C++ and the computer does not understand what you say, he will reply with "Syntax error".

In the code below we will create a mistake intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.

How to handle a syntax error in C/C++?

In the code below we will create a syntax error intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.

Error in Visual Studio

This video demonstrates what happens when you make a mistake in your code. An invalid syntax will always lead to a syntax error. Your code will fail to execute. Here we can see that the "Hello World!" message doesn't get displayed. An error message pops up in the output instead.


When you an error occurs in your program while running, an error message gets displayed in the output (Figure 6). This message contains information on why the error happened and what caused it. This way it is easier for the developer to recognize and fix mistakes. In this case we can see it is a syntax error. The error message tells you that a semicolon(;) is missing.

Figure 6 - Error


The reason for the existence of this document is to show you how to install the tools for coding in C / C++ and it will take you all the way to building and running a Hello World code. This guide is created for introducing you the C / C++ basics and for preparing you to understand and use our C / C++ SMS examples. Using the Ozeki C / C++ SMS solutions is beneficial, because it comes with the full source code and you can use it and modify it without any limitations.

Move on to the next article on the Ozeki website and learn more about C / C++ solutions. Check out the tutorial about how to send SMS from C / C++.

Download the Ozeki SMS Gateway now and set up the system!

More information