Lỗi the system cannot find the file specified trong c++

The system cannot find the file specified"

Lỗi the system cannot find the file specified trong c++

asked Jul 30, 2013 at 12:15

Mr. SupashevaMr. Supasheva

3111 gold badge4 silver badges14 bronze badges

4

The system cannot find the file specified usually means the build failed (which it will for your code as you're missing a # infront of include, you have a stray >> at the end of your cout line and you need std:: 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:


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

answered Jul 30, 2013 at 12:20

Mike VineMike Vine

9,67025 silver badges45 bronze badges

The code should be :


# include 
using namespace std;
int main() {
    cout << "Hello World";
    return 0;
}

Or maybe :


# include 
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)

answered Jul 30, 2013 at 12:22

5

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


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

0 for 32 bit system

in


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

1>


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

2>


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

3>


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

4

Lỗi the system cannot find the file specified trong c++

answered Sep 6, 2014 at 15:19

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


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

5, then you may run into issues.

This is also discussed in more detail here.

answered Aug 19, 2016 at 15:18

Aaron ThomasAaron Thomas

5,0828 gold badges45 silver badges90 bronze badges

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

answered Jan 1, 2014 at 13:11

1

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.