I'm new to C. I was running my code in VSC and somehow when I run the code the first time, it works normally but when I rerun the code, it has an error:
cd : Cannot find path 'C:\Users\phuon\OneDrive\Tai liêu\C C .vscode' because it does not exist.
At line:1 char:1
- cd "c:\Users\phuon\OneDrive\Tai liêu\C C .vscode" ; if ($?) { gcc ...
- CategoryInfo : ObjectNotFound: (C:\Users\phuon...\C C .vscode:String) [Set-Location], ItemNotFoundException
- FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
This is my code
#include <stdio.h>
int findEvenNumber(int y)
{
return y % 2;
}
int main()
{
int number;
printf("Type the number you want to find: ");
scanf("%d", &number);
int even = findEvenNumber(number);
if (even == 0)
{
printf("This is an even number");
}
else
{
printf("This is not an even number");
}
return 0;
}
How could it work the first time, but not the second time?
Anyone have a solution for this?
CodePudding user response:
Visual Studio code (VSCode) is an IDE, not a compiler:
- You need to install VSCode
- Then you need to install a compiler (e.g. GCC)
- Finally, you need to install and configure a plugin (Visual Studio Code "extensions") so that VSCode can use the compiler.
I suspect something is wrong with the "configuration".
SUGGESTION:
- Create a new project, in a new folder.
- Do NOT create your project in a OneDrive folder.
- Create a small, "hello world" C program in your new project.
- See if you can reproduce the problem in the new location.
Please tell us:
- Your compiler and version (e.g. C:\msys64\mingw64\bin\gcc.exe v10.3.0).
- Your extension and version (e.g. Microsoft C/C for Visual Studio Code v1.97).
- Whether or not you have the same problem with the new project in the new folder.