To compile a C++ program, you typically use a compiler like g++. Here’s a simple step-by-step guide:
-
Write your C++ code: Save your code in a file with a
.cppextension, for example,program.cpp. -
Open your terminal: Navigate to the directory where your
.cppfile is located. -
Compile the code: Use the following command:
g++ program.cpp -o program- This command compiles
program.cppand creates an executable namedprogram.
- This command compiles
-
Run the compiled program: Execute the program with:
./program
Make sure you have g++ installed on your system. If you need help with installation or have any other questions, feel free to ask!
