I am very new to C programming and I just installed mingw and started using vs code. I have installed all teh extension required in the VS code and have selected the default builder as gcc in the vs code.
here is the source code I am trying to runmain.c :
#include <stdio.h>int main(){ int age; printf("Hello, world!\n"); printf("Whats your age?: "); scanf("%i", &age); printf("You are %i years old", age); return 0;}
here is the tasks.json which I created:
{"version": "2.0.0","tasks": [ {"type": "cppbuild","label": "C/C++: gcc.exe build active file","command": "C:\\msys64\\mingw64\\bin\\gcc.exe","args": ["-g","-fdiagnostics-color=always","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe" ],"options": {"cwd": "${fileDirname}" },"problemMatcher": ["$gcc" ],"group": {"kind": "build","isDefault": true },"detail": "compiler: C:\\msys64\\mingw64\\bin\\gcc.exe" } ]}
But on building the file (ctrl+shift+B), I get the following error:
> Executing task: C/C++: gcc.exe build active file <Starting build...C:\msys64\mingw64\bin\gcc.exe -g -fdiagnostics-color=always C:\Users\user name\Desktop\username's folder laptop\College CS\C programming\main.c -o C:\Users\user name\Desktop\username's folder laptop\College CS\C programming\main.exegcc.exe: fatal error: input file 'C:\Users\user' is the same as output filecompilation terminated.Build finished with error(s).
I have tried deleting and recreating the .c file.
It works fine when I type the following command in the cmd manually after going into that folder:gcc main.c -o main.exe
So, the gcc works fine but for some reason when I mention the whole path, it goes haywire.
Please help me out as I couldn't find any solutions for this error and sorry of this doubt is a silly one.
I was expecting the build to be successful in VS code but it showed a fatal error even though the VS code is open in that particular folder.