0
#include <iostream>

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

When I try to run this code, this message keeps popping up even though I copied and pasted straight from online. There are no build errors either. Here's the error message

  • Does this answer your question? [Visual Studio complains that .exe is not found when compiling for debug](https://stackoverflow.com/questions/8620939/visual-studio-complains-that-exe-is-not-found-when-compiling-for-debug) – pacukluka May 18 '20 at 00:04
  • What is it, Visual Studio or Visual Studio Code? Chris assumed it's the former, and changed the tag to 'visual-studio'. If you're using VSC, change the tag back and fix the title. And you forgot the error message. – HolyBlackCat May 18 '20 at 00:05
  • Seems not be about compiling but finding the exe as Luka said? – darclander May 18 '20 at 00:06
  • @HolyBlackCat, I based it on the message box with the error having the title "Microsoft Visual Studio". – chris May 18 '20 at 00:07
  • Related to this question? https://stackoverflow.com/questions/8148418/cant-find-exe-after-compilation-succeeds – darclander May 18 '20 at 00:19
  • 2
    There should be a build error. `endl` is in the standard namespace, but you aren't using that. Try: `std::endl` the same way you do with `cout` – RedKnite May 18 '20 at 04:54

4 Answers4

0

Nothing wrong with your code. Could be your antivirus deleting the exe before visual studio can start it. Try disabling your antivirus and run from VS again.

If not antivirus, then something else is deleting it.

Check if the exe shown in the path in your image is really there or not.

pacukluka
  • 728
  • 4
  • 18
0

If you click Build -> Build Solution, you will get an error:

error C2065: 'endl': undeclared identifier.

I suggest you should try to use std::endl

Here is the code:

#include <iostream>

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

And then you could try to run this code: enter image description here

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20
0

I added the file from the new file option not directly from the source file once I created the c++ project.

-1

that error means that the .exe file is most likely still running. it may be that you closed it trough the "X" button, but the VS debugger is still running, so try clicking on the red square to stop it or go in your task manager and manually kill the process.

it may also be that the exe is opened by another process such as a hex editor which is denying further execution access to the file, but i have had this issue personally before and the fix above worked.

tb044491
  • 144
  • 7