0
votes

I am trying to do a simple code in C using the text editor Sublime. The problem is, when I try to use the scanf function I get an error.

#include<stdio.h>
#include<stdlib.h>

int main(){
    int a;
    scanf("%d",&a);
    printf("testing %d",a);
    return 0;
}

The error:

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot open output file cccc.exe: Permission denied collect2.exe: error: ld returned 1 exit status

1
This just seems like a permission problemBpaul
Your code compile ok, a live test of it: segfault.stensal.com/a/b0nHamZUXjg1hFP4. This is not a C question, it's your file permission problem.stensal
try omitting the scan ... a = 42; //scanf("%d",&a);pmg
In general it is always a good idea to include your error/warning in text in the body of your question.hat
scanf gathers input from stdin; programs executing in Sublime's output panel have no stdin connected to them; thus they hang forever waiting for input that you cannot provide. You assume your code is broken and try to run it again, but the previous version is already running, which has the file locked, and the linker is unable to relink. Extremely common problem (but finding it on SO is very difficult). The answer to the question is to not run interactive programs directly within Sublime.OdatNurd

1 Answers

1
votes

You may have another instance of g++ open in cmd. You may be running "a.exe" generated by g++ in Command Prompt. Due to the fact that a file already exits, and is being used, you can not create a file of same name.