Debug Visual Studio 2107 C++ program error

Can't get VS to compile simple hello world.

Project created as desktop folder Demo1(Desktop\c++\demo1\demo.cpp

Code:

#include <iostream>
using namespace std;

int main() {
cout << "Never fear, C++ is here!" << endl;
system("Pause");
return 0;
}


Compiler output from Build:

1>------ Build started: Project: demo1, Configuration: Debug Win32 ------
1>Object reference not set to an instance of an object.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Can't see the issue with this simple program.

Assistance will be appreciated.

Thank you.
Hello max4949,

That message is nice, but it came from the output window.

What is the actual error message from the "Error List" window?

If you do not fine the "Error List" tab somewhere along the edge of the IDE window go to "View -> Error List" to view the full error.

Question: did you let the IDE's wizard create the solution for you or did you create an empty project?

I have not had this problem before although I have not stored a solution on the desktop before. I have to give it a try and see what happens.

Andy
closed account (E0p9LyTq)
Steps for setting up a project/solution in Visual Studio 2017:
https://www.learncpp.com/cpp-tutorial/writing-your-first-program/

One step that tutorial misses that I think is critical is creating an empty project. An empty project you add your source files manually without a lot of MS added code stuff.

Hello max4949,

I tried to duplicate your problem, alas could not.

You said that this is your path:
Project created as desktop folder Demo1(Desktop\c++\demo1\demo.cpp
I have the feeling that this is wrong.

But when I ran my VS and wanted to use the Desktop to put my solution I ended up with:
C:\Users\andy\Desktop\Test project\Test project\Main V1.cpp

This part of the path C:\Users\andy\Desktop\ can be anything. Normally I use F:\VS 2017\ as the base path and what comes after that, the two subdirectories, is added by VS.

I am guessing that if the path, including the subdirectories, is not correct than VS is not finding the correct path and file.

Without knowing what you did to start with it is difficult to know where you went wrong. You may have to explain your steps when creating this program.

Hope that helps,

ANdy
Topic archived. No new replies allowed.