How to Run C and C++ Program in Sublime Text

In this tutorial you will learn how to run C and C++ program in sublime text on windows.

It is a very popular and widely used text editor by programmers and developers. Just follow below steps to configure sublime text to compile and run C and C++ programs. I have tested the steps in sublime text 3 but I am sure it will work for any other version also.

Also Read: Configure Notepad++ to Run C, C++ and Java Programs

How to Run C and C++ Programs in Sublime Text

How to Run C and C++ Program in Sublime Text

Here I consider that you have installed GCC compiler on your system.

Part 1: Adding Path in Environment Variables

1. Copy the path of bin folder of GCC compiler. In my case the path looks like as shown below, it may be different in your case.

C:\Program Files (x86)\CodeBlocks\MinGW\bin

2. Now right click on Computer and select Properties. Then click on Advance system settings and after that click on Environment Variables.

3. In the next window under System variables find a variable with name Path. Select it and click on Edit button.

4. In Variable value text field go to end and then type semicolon and then paste the path of bin folder that you copied. See below screenshot.

How to Run C and C++ Programs in Sublime Text

5. Finally click on all OK buttons to save the settings.

Part 2: Configuring Sublime Text

Open sublime text and go to Tools > Build System > New Build System and then paste the following lines in it.

For C:

Press ctrl+s and then save it with file name C_RUN.

For C++:

Press ctrl+s and then save it with file name CPP_RUN.

For running a program go to Tools > Build With and then select C_RUN – Run or CPP_RUN – Run according to the language you are using.

Video Tutorial

If you have any query then ask in comment section, I will try to solve it.

One thought on “How to Run C and C++ Program in Sublime Text

  1. Aismita Dey

    I have followed all your steps still the output is not coming rather it is showing:” ‘gcc’ is not recognized as an internal or external command,
    operable program or batch file.
    [Finished in 0.6s]”
    Kindly help.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *