Install GNU GCC C++ Compiler
This tutorial will teach us to compile and execute a C++ program using the Windows command line prompt. Steps to install GNU GCC C++ compiler:
Write C++ code
General steps to execute the program are as follows:
- Launch Text editor like Notepad, Notepad++, etc.
- Write C++ source code.
- Save the file with the .cpp file extension. For Example, we will save the file as main.cpp
/************************************ * Hello World C++ Program * Filename: main.cpp * C++ Tutorials - www.TestingDocs.com *************************************/ // C++ Header file #include using namespace std; // Entry Point : main routine. int main() { cout << "Hello, World!"; // print message return 0; }
Compile C++ Program
Open the Command prompt and issue the following command to compile the code.
\> g++ main.cpp
If there are no errors in the code a.exe executable file would generate.
Execute C++ Program
Now, type ‘a.exe’ to run the C++ program. You would be able to see ‘ Hello, World !’ printed on the console.
That’s it. We have successfully compiled and executed a C++ program using the Windows command prompt.
—
C++ Tutorials
C++ Tutorials on this website:
https://www.testingdocs.com/c-coding-tutorials/