i just started to code in cpp and nothing is working idk if i didn't install the gcc properly or what but i already set the path of the bin file idk why it refuses to run the code:
#include<iostream>
int main()
{
std::cout<<"hello";
}
and the problem is that when I try to use the "code runner extension" it is not working so I just press f5 and then when I get the error messages which says at first "could not find the task file'c/c :g .exe build active file' " and I get three options 1:debug anyway 2:configure task 3:cancel when I choose debug anyway I get this error here
CodePudding user response:
Since you're on windows consider installing Visual Studio or CLion. They're more beginner friendly - VSCode can get tricky to run c on windows. Either way, looks like you're trying to run your project without building it first. There should be a build option right next to the run option. Try building it, then running. The build is what compiles and creates the project.exe file, which is what the compiler is saying isn't there.
The referenced IDE's always auto-build on run, so there's that
CodePudding user response:
If you're familiar with using the command line, these commands will do what you want, assuming the .cpp
file is in your current directory.
g <FILENAME>
./a.out
There are wonderful flags you can add to the first command (the compiling command) like -Wall
, -Wextra
, -o
, and many more. But, since it seems like you're just starting out, there's no need to worry about those!
If you're not familiar with the command line, I would encourage you to become familiar! It is an extremely powerful tool for a programmer. Here is a YouTube video that talks about it.