Hello World: How to compile cpp/c++ code.
c++ compiler
There are many c++ compiler nowadays, the most popular and complete c++ compilers are:
You can go to their homepage and find how to download and install.
c++ compiler
And also, c++ sycl compiler can build standard c++ code too:
You can write c++ code with most text editors, there are many text editors you can find on Internet, such as notepad, featherpad, cpeditor, vim, kakoune, emacs, visual studio ide, etc.
I am using kakoune kak editor, it is a good c++ code editor. (Home)
c++ code
First, copy the following c++ code to a text editor, and save it as prog.cpp :
#include <iostream> int main() { std::cout << "Hello World! This is a c++ program!" << std::endl; }
Build it with gcc c++ compiler
g++ prog.cpp -std=c++23 -o prog
The generated program of the code is prog .
Run the program
Run:
./prog
Output:
Hello World! This is a c++ program!
In this article of this day, all you have to do is downloading compiler, installing compiler, copying above c++ code, building and running. I guess you can finish them within 10 minutes, you can continue to learn day-02 article in the same day now. So then, day-01 and day-02 articles can be finished in one day.
Written on Aug 03, 2024
c++ std::exception:
std::cout.write(err.data(), err.size());
std::cout << std::endl;
caught:
================================================== # The c++ programming language. # # # # Home: cppfx.xyz # # Join c++ Discord: yZcauUAUyC # # Deck # ==================================================