having an error i cant fix

jay bezek 1 Reputation point
2021-08-11T00:06:02.317+00:00

ive been getting this error

Unable to start program'c:\users\user\document\visual studio 2010\
Projects\HelloWorlds\Debug\HelloWorlds.exe'.
The system cannot find the file specified.

and have no idea how to fix it. i have a .cpp file and have put it in different areas in my file directory. i am using the latest version of visual studio.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,960 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,351 Reputation points Microsoft External Staff
    2021-08-11T01:46:38.96+00:00

    Hi,

    According to the description, whether you only have a .cpp file and want to run this .cpp directly? If so, as far as I'm concerned you couldn't run the .cpp file directly in visual studio. You could only run the .sln file (Visual Studio Solution).

    I suggest you could create a console project and add the .cpp. Then try to build and run the project.

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. WayneAKing 4,931 Reputation points
    2021-08-11T02:07:49.44+00:00

    Also see this thread:

    https://learn.microsoft.com/en-us/answers/questions/494574/visual-studio-not-creating-exe-for-c-program.html

    Note that VS creates exe files by building projects. You can't
    just open a CPP file in the IDE editor and Build or Run and
    expect the code you are looking at to be part of the project that
    creates the exe. It must be a source file shown for the project
    in the Solution Explorer.

    You haven't said anything about how you created the project - if
    at all - and how you added your code to that project. One way
    is to right-click on the Source node in the project tree in the
    Solution Explorer and choose Add to make a new or existing CPP
    file part of that project.

    Another is to use the appropriate Project Template such as
    "Win32 Console" and modify the source file that it creates
    automatically.

    Always do a Build or Rebuild first before trying to Run the
    program. Fix all errors and warnings shown in the Build
    window before trying to Run the program. Always start
    fixing errors from the top down - fix the first error,
    then the next, etc. Don't just look at the last error and
    wonder why it occurred - errors often cascade and later
    errors happen because of prior errors. Often fixing one
    error can clear up many subsequent error messages.

    If the Build shows errors that you don'r understand,
    show them here and the code that caused them (copy
    & paste actual code, don't try to retype it in a post
    as that often leads to errors or omissions).

    • Wayne
    0 comments No comments

  3. WayneAKing 4,931 Reputation points
    2021-08-11T04:25:11.48+00:00

    When you installed VS did you include the Windows SDK component(s)
    in the installation?

    The C language Runtime Library (CRTL) is incorporated in that library.

    • Wayne
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.