I cannot execute some C codes by Sublime Text 3

Asked

Viewed 249 times

0

I have a folder with some simple C codes, I can compile, but the code does not run correctly in the terminal of sublime text 3.

Does not return any information or display this message due to the code being looped:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot open output file teste.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
[Finished in 1.2s]

I tried the solution of a problem similar to mine here in stack overflow, searching for the service "Application Experience", but this service is not appearing on my computer, besides the problem is a little different.

I’m using the build configured this way:

{
    "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe"],
    "selector" : "source.c",
    "shell" : true,
    "working_dir" : "$file_path",

    "variants":
    [
        {
            "name": "Run",
            "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe","&&", "${file_base_name}.exe"]
        }
    ]
}
  • Provide more details on your question to get richer, tell us which IDE you are using, how you are using it etc..

  • It seems to me that the message: "cannot open output file test.exe: Permission denied" is quite clear. You are trying to write the "test.exe" file to a folder for which you do not have the proper permissions.

  • But how does this explain the fact that I can compile and execute other C codes in the same folder, in addition to other languages like C++ and Python?

  • The file must be running in a loop. If applicable va security options([CTRL]+[ALT]+[DEL]) select the task manager and look for its executable and close it.

  • 1

    @Augustovasques I just checked, the code is being compiled, is executed, but does not return anything and is still running, while running the code again occurs the denied permission error. Now I need to figure out why I’m not returning any information.

  • I made some fixes in the post, due to the problem not being identified correctly at first.

Show 1 more comment

1 answer

0


After some research and testing, I discovered that the Sublime Text terminal does not accept entries. Therefore, when running the executable directly by the editor, the C-language program loops and cannot display anything. I tested by removing input functions like 'scanf and getchar' in the C language and 'input' in a code in the python language. In the case of python, the instructions after the input command are not displayed, I believe this difference of how they are executed is due to one language being compiled (C) and the other interpreted (Python).

The solution I found is to run the program directly in cmd or powershell.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.