CC++Introduction to C++Learn C++

How To Run A C Program In Terminal

How To Run A C Program In Terminal

C is one of the most powerful programming languages. You can write C programs for free using various C/C++ compilers and IDEs. Using a fast and reliable C or C++ compiler for Windows is very important for beginners and professionals since it helps C/C++ developers in remembering which language features exist, how to use them, and even detect errors when we get them wrong. C language still popular among developers and it has many pre-defined variables, functions, and libraries.

Today we have many free C++ IDE and compiler tools like C++ Builder CE, Dev-C++, BCC32 Compiler, VS Code, among others. C++ Builder has a free C++ Builder Community Edition and for professional developers there are C++ Builder Professional / Architect / Enterprise Versions.

C++ Builder is a modernized professional IDE with great C and C++ compilers to create amazing C++ software for the different OS platforms. The C++ Builder IDE and its C and C++ compilers have many modern features to develop professional apps. Recently there was a new release of RAD Studio / C++ Builder version 11.1.5 which came with an update to the Code Insight feature. This is a ‘quality release’ focused on C++ Code Insight and related features for C++ … Continue reading

292669203 10159281964412499 2865954964395779081 n 2548541

How to run C program in Terminal with C++ Builder

You can run C code using most C++ compilers and build tools like C++ Builder.

1. If you don’t already have a C++ compiler, download free C++ Builder Community Edition and install it.
2. In C++ Builder, create a new console application from the File->New->Console Application – C++ Builder menu. Chose C Language as a Source Type and Target Framework as None from the next window and pres OK. ,

If you are new to programming, here is a quick introduction to create a simple C Program. C Programs (C Codes) is a text file, which means you can use any editor to edit these kinds of programs. Notepad, Notepad++. But C++ IDE’s have more features to edit and run C Programs.

helloworld 4006165

When you start coding, first of all, you should include libraries that you use. Generally, for beginners stdio.h library is enough to do simple beginner apps. We can include this library as below,

Second, you should add the main procedure (the main program, the main function) as below,

After that you should write your programming code lines into this procedure, between { and } brackets. If you are a beginner “Hello World” examples are good to understand feature of that programming language. It is good to understand how to edit text, how to write in its format, how to compile and link, how to debug and execute, how to deploy or release. This full example below is a “Hello World” C example that can be run with C++ Builder.

In C++, after every command you use you should put ; to the end of your commands. In this example above we print a text with printf() function and then we wait to get a character input (key press) with getchar(); functions, then we exit and return 0; which means our main app successfully run and exit.

In this example above we define main() function as a integer (int) function, that means we should return a integer value. Here, we print a text with printf() function and then we wait to get a character input (key press) with getchar(); function, sometimes this is necessary to see results when running it. Then we exit and return 0; which means our main app successfully run and exit.

3. You can simply press Run Button or F9 key to compile and run, or you can use Menu to compile and Run too.

4. If you want to run this program in Console then execute RAD Studio Command Prompt from the Windows menu in Windows. This will open Command Console (Terminal) with RAD Studio / C++ Builder configs. After this step, in Terminal, go to folder of your C file and type bcc32 and your file name. For example you can compile your app as below,

To run your compiled app, you can type compiled executable file name which has .exe extension with the same base name as your C file. For example, to run compiled myapp.c file write its executable output as below,

How to run a C program in the Terminal or command prompt with a free C++ Compiler?

bcc32c 760 3380590

You can simply use the bcc32 C++ compiler to compile C programs in the terminal or command prompt. For example, if your c program file is myproject.c you can compile this with optimization level 2 (-o2) as below,

How to run a C Program in the Terminal or command prompt window using a GNU C/C++ Compiler?

GNU GCC is another powerful C/C++ compiler originally written as the compiler for the Unix, Linux and GNU operating system. The GNU system was developed to be 100% free software, and it is efficient with both 32-bit and 64-bit operations. This compiler can be used on Windows using MinGW or CygWin Linux Simulators. Compiled executable files need a small dll to run independently on Windows. It is mostly compatible with CLANG standards.

The GCC Compiler can be used by Visual Studio Code, Dev C++, Code Blocks, and can be directly used within the Command Prompt or PowerShell. It is available on the official product page https://gcc.gnu.org/.

GNU C/C++ compilers can be directly used in Linux or it can be used with MinGW Linux Simulation (with GNU C/C++ Compiler) to develop C++ applications running on the command console. It is the most well-known compiler in Linux.

How to execute a C program in Linux terminal?

In Linux, GNU C/C++ comes as default language installed. Generally, the gcc compiler is used as a C compiler but the g++ compiler is used as C++ compiler. If your c program file is myapp.c you can compile this with gcc command as below,

Be sure that you have permission to write to folder there. Now you can easily run your myapp.out as given below,

Here is the full input and output process in Linux terminal

How to run C program In Terminal or the command prompt with a Professional C++ compiler?

cbuider studio final icons 64 9744851 4964591 6127446 4112068 5843153

In general, you can run c programs with the latest C++ Compilers and Editors today. C++ Builder Professional, Enterprise and Architect Editions are able to run C programs. There is a free C++ Builder Community Edition for students, beginners, and startups too. Simply you can download, install and run your C programs in console applications. Moreover you can enhance your C programs with C++ features and modern GUIs, which means you can mix and use C and C++ together. For the best modern app, later if you wish, you can update your C program to a C++ program.

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, macOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio, and C++ Builder is one of the most professional IDE’s that work under RAD Studio. It is the oldest IDE (it began as Borland TurboC in 1990 and was later renamed Borland C++ Builder). Under the Embarcadero brand, multiple new versions have been release, year upon year, along with great new features, updates, and support to ensure that your apps can stay current. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

rads11 1u1light welcome 9155681
The Latest RAD Studio C++ Builder Welcome Screen

You can simply use the RAD Studio Command Prompt to compile and execute C programs in terminal. For example, if your c program file is myproject.c you can compile this with optimization level 2 (-o2) as below,


Download RAD Studio 11 Now

See What’s New in RAD Studio 11

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?