Ch1.3 – The first project – Hello World and a little more

Now you have a new project TestConsole01 and it’s auto-generated code.

Basically this code will display “Hello World” on console window.

Every program has a starting point. Sometimes it is called Entry Point of the program.

The term Entry Point is used as a different meaning in server-client programing but it is fine to call it Entry Point here.

In C++, any console application’s starting point is main() function.

What is this mean? Launching application means the Operating System calls the Entry Point of the application.

This Entry Point is what we called exported function, means this Entry Point (basically a function) is exported to OS so OS can call it.

So launching application basically means, OS will load the application into the memory and call the exported function (entry point) main().

Once main() function is finished, the control is return to OS and OS got it as the end of the application execution and unload the application from the system memory.

 

The Operating System (Windows system) will call main() function of the application.

Now let’s see the application source code. This is real simple application that display “Hello World!” on console screen.
Console screen means Command Prompt box.

The application will start from main() function.

There is only one line of code in this main() function.

std means standard I/O (input/output) class and cout is a member function of std class. We will handle class definition, member variables and member functions when we learn C++ language structure.

<< is input operator and “Hello World!\n” is a string definition.

std::cout << “Hello World!\n” means send “Hello World!\n” string to std::cout function.

std::cout function will take the string as a parameter and display the string in console window.

 

Now let’s launch this application from Visual Studio IDE(Integrated Development Environment).

Choose Build -> Build solution menu.

Then, you will see VS build the application as the red box in the below screen.

Once the compile is done, choose Start Debugging or Start Without Debugging will launch the application.

Once it is sucessfully launched, you will see a console window is opened, and Hello World! is displayed on console window screen.

 

Scroll to top