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

How To Compile And Run A C Program

C is one of the most popular and versatile programming languages and being able to compile and run a C program can be a valuable and in demand skill. C and C++ Compilers are great tools to develop with when they are paired with a professional Windows C IDE such as RAD Studio and C++ Builder.

What is the history of the C programming language?

The C Programming Language was developed in the 1970s and since 1970, C has inspired the invention of a vast array of other programming languages, such as C++. The C++ programming language includes a substantial number of elements of the C language and builds on those solid foundations with object-oriented programming features like Classes, Objects, and Methods. Still, this oldest genie language is popular, mostly in the top 3 but if we consider its other variations and its usage on microchips and IoTs it is the most used programming language.

A C or C++ Compiler is a computer program that converts the high-level instructions of the programming language (i.e. C/C++ source code) written with text into executable machine code in partnership with a linker. In general, all computers work with machine code executable packages – code that can be directly run by the operating system. This is the most low-level and fastest code, but it requires writing many lines for simple things and is hard to generalize for all kinds of machines.

The term C++ IDE refers to the entire integrated development environment. Technically. the compiler is the part of the C++ IDE which interprets the program’s source code and converts it in object code. This object code is the ‘linked’ by another related process called, perhaps unimaginatively, the linker. The entire C++ IDE includes the specialized text editor in which the programmer writes the program’s source code and designs the screen layouts as well as menu options or shortcuts to tell the C++ compiler to compile the source code and the linker to link it into the final program executable or app package.

Most C compilers only ‘understand’ programs written in the C programming language. However, since C++ is a mostly a kind of superset of the C language you will find that the C++ compiler can compile nearly all C programs too. This is definitely the case for C++ Builder which can compile both C and C++ source code without any problems at all.

Download the latest C++ Builder for free to compile and run a C program

The C++ Builder CE version is free C and C++ IDE for building simple or professional applications on the Windows, 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 IDEs that work under RAD Studio. C++ Builder comes from a venerable history which began with the incredibly popular Borland TurboC in 1990. This was later renamed Borland C++ Builder. Under the Embarcadero brand, it comes with new versions, features, updates, and support. 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. There is a free C++ Builder Community Edition for students, beginners, and startups.

How To Compile And Run A C Program the RAD Studio C++ IDE
RAD Studio C++ Builder 111 Patch 1 IDE and Compiler Welcome Screen

Here are the features of the C++ Builder 11 version;

  • Provision apps for Windows 11
  • Compile for Android API 30
  • Compile for M-series (Apple Silicon) processors
  • Design on high-DPI 4k+ screens
  • View VCL Styles in design time
  • New & modernized VCL components  
  • Use enhanced remote desktop support to collaborate remotely 

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.

See What’s New in C++ Builder 11

Download C++ Builder 11 Now

How to compile and run a C program with the C++ Builder IDE?

You can use C++Builder to develop a C console application, or to develop a C++ console application or a C++ Visual Application with GUIs like buttons, edit boxes etc. C++ Builder is a good tool to develop C and C++ applications from the beginner level to higher professional levels.

How to start coding in C++ Builder to compile and run a C program for the terminal or command line

  1. Install and run the latest RAD Studio or C++ Builder CE
  2. Create a new Console Application from the File->New->Console Application C++ Builder menu as below,
How To Compile And Run A C Program creating a console application

3. In the next window, select Target Framework as None and If you are sure you will use C language only then you can select C language. If you want to use C language and may be you can use C++ features in the same code, then you can select C++ source type. And press OK to create a new application.

How To Compile And Run A C Program picking the target framework

4. Now, you can start to write your first C codes into Code Editor of C++ Builder IDE. Here is a simple Hello World example as below,

How To Compile And Run A C Program a hello world C program in the C++ Builder IDE
RAD Studio C++ Builder IDE 1115

Here, first add library headers with #include < > command. Then we define our main() program with { and } .Between these we write our main program. We can use printf(” “); function to write text outputs. Then we can wait for a character input (a key press) by the getchar(); command. Finally we can write return 0; to let application know it is done successfully. If you have problem to type you can use this full example below.

5. Now we can compile and run our application.

Press Run Button or just Press F9 to compile and run your first C example. You can use Run menu too.

How to compile and run a C program in with the RAD Studio Command Prompt and MSBuild?

If you create and save your C++ Builder C development project as described above, you can run RAD Studio Command Prompt.

1. First be sure that RAD Studio or C++ Builder is installed and the project and C files of this project is saved in a folder.
2. Press Windows Key and write “RAD” then in Windows Menu choose” RAD Studio Command Prompt”. This will execute Command Prompt with RAD Studio settings.
3. Use CD command to navigate to your project folder. For example,

4. type dir command to see your C project files
5. *.cbproj file is your project file. Use msbuild to use MS Build app. This will build your application with project settings, it will use appropriate c compiler and linker defined in this project file. For example,

6. This will compile and list you errors and warnings as given example below,

How To Compile And Run A C Program the RAD Studio command prompt

7. The executable file is generated in an output folder. This folder can be Win32, Win64, iOS, Android etc. You can check these folders by cd and dir commands. And also project can be in Debug or Release folders, depends on your project. Our project was 32bit Windows Console Application (Win32) and it was in Debug mode (Win32\Debug folder). So we can navigate to Win32 and Debug folder as below,

If you type dir command you will see all output files in Debug folder as in example below,

8. Now you can execute the executable *.exe file

How to compile and run a C program in the Terminal or command line with RAD Studio command prompt and compiler?

If you don’t want to use project settings and you just want to compile a *.c file you can use compilers listed in bin directory of C++ Builder or RAD Studio. For example for an 32bit Windows application you can use C++ Builder Compiler for Windows 32bit bcc32.exe as below,

or you can use bcc32c C++ Builder CLANG Compiler for Windows 32bit as below,

Note that when you compile a C file in this way, compiler will generate all exe and other output files to the same folder.

Don’t forget, you can also use Borland C++ Compiler and Dev-C++ to compile C programs. We highly recommend you use C++ Builder CE version that may allow you switch to the professional version easily.

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

For students, beginners, and startups you can download a free C++ Builder Community Edition. If you are a professional developer, you can download a free trial copy of Professional, Architect, or Enterprise versions of C++ Builder.

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.

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++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?

C++C++17C++20Introduction to C++Language FeatureLearn C++Syntax

Learn How To Use Clamp (std::clamp) In Modern C++ 17 and Beyond