I keep getting this error with these lines of code:
include <iostream>
int main()
{
cout << "Hello World" >>;
system("pause");
return 0;
}
"The system cannot find the file specified"
I keep getting this error with these lines of code:
include <iostream>
int main()
{
cout << "Hello World" >>;
system("pause");
return 0;
}
"The system cannot find the file specified"
Another take on this that hasn't been mentioned here is that, when in debug, the project may build, but it won't run, giving the error message displayed in the question.
If this is the case, another option to look at is the output file versus the target file. These should match.
A quick way to check the output file is to go to the project's property pages, then go to Configuration Properties -> Linker -> General (In VS 2013 - exact path may vary depending on IDE version).
There is an "Output File" setting. If it is not
$(OutDir)$(TargetName)$(TargetExt)
, then you may run into issues.This is also discussed in more detail here.
The system cannot find the file specified usually means the build failed (which it will for your code as you're missing a
#
infront ofinclude
, you have a stray>>
at the end of yourcout
line and you needstd::
infront of cout) but you have the 'run anyway' option checked which means it runs an executable that doesn't exist. Hit F7 to just do a build and make sure it says '0 errors' before you try running it.Code which builds and runs:
The code should be :
Or maybe :
Just a quick note: I have deleted the system command, because I heard it's not a good practice to use it. (but of course, you can add it for this kind of program)
This is because you have not compiled it. Click 'Project > compile'. Then, either click 'start debugging', or 'start without debugging'.
I had a same problem and this fixed it:
You should add:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64
for 64 bit systemC:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
for 32 bit systemin
Property Manager
>Linker
>General
>Additional Library Directories
Oh my days!!
Feel so embarrassed but it is my first day on the C++.
I was getting the error because of two things.
I opened an empty project
I didn't add #include "stdafx.h"
It ran successfully on the win 32 console.