Back to Course

Introduction to C++

0% Complete
0/0 Steps
  1. C++: Basics
    5Topics
    |
    6 Quizzes
  2. C++: Compilation and Execution
    5Topics
    |
    6 Quizzes
  3. C++: Variables
    9Topics
    |
    10 Quizzes
  4. C++: Conditions Operators
    5Topics
    |
    6 Quizzes
  5. C++: Logical Operators
    3Topics
    |
    4 Quizzes
  6. C++: Loops and Errors
    8Topics
    |
    9 Quizzes
  7. C++: Vectors
    4Topics
    |
    3 Quizzes
Lesson 2, Topic 3
In Progress

C++: Naming Executables

Yasin Cakal 30 Oct 2021
Lesson Progress
0% Complete

Execute:

Sometimes you might want to name the executable file rather than its default name. To name an executable, the method is slightly different. Let’s try this for the hello world.cpp file.

You still have to write the first part g++ hello world.cpp in the terminal. However, to rename the file, you add -o followed by the name you want to give to the executable file. Let’s name the executable file hello. Type this into your terminal:

g++ hello world.cpp -o hello

With this, the hello world.cpp file will be translated into a machine code file named hello.

Execute:

To execute the machine code, it can be called in the terminal and executed to display output. To execute a machine code file named hello, type ./ followed by name of the executable. It will appear like this:

./hello

This loads the executable into the computer memory and it will be executed by the CPU according o instructions.

Responses

Leave a Reply

%d bloggers like this: