Sublime Forum

C Program is not compiled

#1

hello, today I am trying to run a c program in sublime text but i am unable to run the program on sublime Text3. Steps that followed by me.

  1. Copy C:\Program Files (x86)\CodeBlocks\MinGW\bin

  2. PATH Variable: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\CodeBlocks\MinGW\bin

  3. I have written This C Program
    Coding:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int a=5,b=10;
    printf(“The sum of %d and %d is %d”,a,b,a+b);
    getch();
    }

  4. and save it as GCD.c

  5. Then I got this message:

  6. Please solve my problem as soon as possible.
    you can contact me by
    mail: nmandalstu@gmail.com
    whatsapp: 09475889780

0 Likes

#2

The short version of your problem is this:

  1. You used getch() in your program, which makes it wait for you to press a key before it continues execution, which in your case is just to end the program.

  2. You ran your program in Sublime, and it did what you wanted it to do

  3. Now your program is sitting in the background waiting for you to press a key so that it can continue and exit, but you can’t interact with it because you can’t give input to running programs in Sublime when you run them this way

  4. When you try to build again, windows can’t re-link the file because it’s already running, which means the file is locked. Instead it gives you a permission denied error

So the answer for you is:

  • Select Tools > Cancel Build (or use the key binding it says there) to stop the blocked background version from running first, so that you can build and run it again

  • Remove the getch() call if you’re going to run your program in Sublime

0 Likes