Home > Articles > Programming > C/C++

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Running Your Program

You can now run the executable by simply typing its name on the command line1:

$ a.out
Programming is fun.
$

1. If you get an error like this: a.out: No such file or directory, then it probably means the current directory is not in your PATH. You can either add it to your PATH or type the following instead at the command prompt: ./a.out.


You can also specify a different name for the executable file at the time the program is compiled. This is done with the –o (that's the letter O) option, which is followed by the name of the executable. For example, the command line

$ gcc prog1.c –o prog1

compiles the program prog1.c, placing the executable in the file prog1, which can subsequently be executed just by specifying its name:

$ prog1
Programming is fun.
$
  • + Share This
  • 🔖 Save To Your Account