Site icon Learn C++

How To Execute A C Program In Terminal

How To Execute A C Program In Terminal

C is one of the most powerful programming languages. You can create simple programs written in C using free C build tools and compilers that are available for the different operating systems like Windows, iOS, and Android. It has many pre-defined variables, functions, and libraries. Using a fast and reliable C++ compiler for Windows is very important for beginners and professionals since it helps C++ developers in remembering which language features exist, how to use them, and even detect errors when we get it wrong.

You can run a C program using the C or C++ compilers and build tools included with C++ Builder. C++ Builder has a free C++ Builder Community Edition as well as commercial C++ Builder Professional / Architect / Enterprise Versions with more extensive capabilities suitable for those who wish to go further with development or who do not fall within the restrictions of the Community Edition license terms.

As a C++ compiler, I believe the best professional C++ IDE and code editor to implement C++ Programs for Windows, iOS and Android is the latest version of RAD Studio or C++ Builder,

How To code and wxecute a C program In Terminal?

If you are new to programming, here is a quick introduction on how to create a simple C Program. C Programs (C code) is a text file, which means you can use any editor to edit these kinds of programs such as Notepad, Notepad++ and so on but a proper C++ IDE has much more dedicated features to edit and run C Programs. Suitable IDEs include Dev-C++, RAD Studio, and C++ Builder.

Before we get started, you should download and install a free C and C++ compiler and IDE.

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

[crayon-663603e40cbaa060866658/]

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

[crayon-663603e40cbb1634025448/]

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.

[crayon-663603e40cbb3117430828/]

In C and 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.

How to execute a C Program in Terminal with a free C++ Compiler?

There are different Embarcadero C++ Compilers for different purposes. These are bcc, bcc32c, bcc32x, bccaarm, bcc64 executable compilers. developed 2012-2022 Embarcadero Technologies, Inc. There is a free Win32 compiler officially listed as a free C++ Compiler in the Official Web Page of Embarcadero.

This free download of the C++ Compiler includes C11 language support, the Dinkumware STL (Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker and resource compiler.

The Free C++ Compiler download includes:

C++Builder includes compilers for Win32, Win64 and iOS. And, C++Builder also features a modern, high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform UI development. Learn more about RAD Studio on its product page.

How to execute a C program in terminal?

You can simply use one of these C++ compiler to compile C programs. For example, if your C program file is myproject.c you can compile this with optimization level 2 (-o2) as below,

[crayon-663603e40cbb5950167818/]

How to execute a C program in Terminal with A professional C++ compiler?

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. 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.

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,

[crayon-663603e40cbbf003388465/]

You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.

Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.

Download RAD Studio 11 Now

See What’s New in RAD Studio 11

Exit mobile version