[c++] The system cannot find the file specified. in Visual Studio

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"

enter image description here

This question is related to c++

The answer is


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 system

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib for 32 bit system

in Property Manager>Linker>General>Additional Library Directories


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.


This is because you have not compiled it. Click 'Project > compile'. Then, either click 'start debugging', or 'start without debugging'.


I resolved this issue after deleting folder where I was trying to add the file in Visual Studio. Deleted folder from window explorer also. After doing all this, successfully able to add folder and file.


The code should be :

#include <iostream>
using namespace std;

int main() {
    cout << "Hello World";
    return 0;
}

Or maybe :

#include <iostream>

int main() {
    std::cout << "Hello World";
    return 0;
}

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)


Oh my days!!

Feel so embarrassed but it is my first day on the C++.

I was getting the error because of two things.

  1. I opened an empty project

  2. I didn't add #include "stdafx.h"

It ran successfully on the win 32 console.