Why doesn't my output work and keeps running when executing code?

45 views Asked by At

My output isn't working since I tried (and failed) to use mysql with c on vs code(W11). More precisely the program can get executed in the terminal, and only works in the output when I haven't put a function that asks the user to write something (scanf,fgets...) if I put a scanf, gcc compiles but doesn't execute anything and put "running". I know I could just activate the run in terminal option of code runner but I would like to execute it in the output that I find cleaner and was working properly before. Here is my settings.json file:

 {
      "npm.exclude": "",
      "C_Cpp.default.includePath": [
        "C:\\Program Files\\MySQL\\MySQL Server 8.0\\include"
      ],
      "cmake.configureOnOpen": true,
      "cmake.showOptionsMovedNotification": false,
     "editor.formatOnSave": true,
      "notebook.formatOnSave.enabled": true,
      "notebook.codeActionsOnSave": {},
      "[c]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
      },
    
      "code-runner.saveFileBeforeRun": true,
      "liveServer.settings.AdvanceCustomBrowserCmdLine": "",
      "phpserver.phpConfigPath": "C:\\xampp\\php\\php.ini",
      "phpserver.phpPath": "C:\\xampp\\php\\php.exe",
      "launch": {
    
        "configurations": [],
        "compounds": []
      },
      "C_Cpp.clang_format_style": "Visual Studio",
      "code-runner.clearPreviousOutput": true
    }

Here is the simpliest example which doesn't work:

#include <stdio.h> 

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

Here is what the output says:

[Running] cd "c:\Users\Thiba\OneDrive\Documents\Travail\HTML\test\" && gcc lqla.c -o lqla && "c:\Users\Thiba\OneDrive\Documents\Travail\HTML\test\"lqla

and is still running, I have to stop it myself then I have:

[Done] exited with code=1 in 118.666 seconds

Thanks for your help!

I tried to change the settings of code runner,

I uninstalled and reinstalled vs code, I executed a program with the command prompt to verify that the problem wasn't from the compiler (gcc), I tried modifying all of the json file in my project (different from the global settings.json file), I tried opening another project/directory. I have seen several forums but the conclusion was just to activate the run in terminal option

0

There are 0 answers