# Solved: C++ 2010 not debugging



## SpectresShadow (Aug 3, 2012)

When I write a program in c++ and try to debug, I get an error pop-up (see attached photo). I have been using just the simple hello world program to try to figure out why it is happening.


```
#include <iostream>
using namespace std;

int main()
{
     cout << "Hello World" << endl;
     system("Pause");
     return 0;
}
```
And yes, I know that using the system command is bad convention, but I only use it for debugging. My finished products always have the getch() command in place of system("Pause").

If anyone has any ideas on what to do, I would appreciate the help. Thanks in advance.


----------



## Ent (Apr 11, 2009)

Have you verified that the file does actually exist?


----------



## SpectresShadow (Aug 3, 2012)

Yes I have checked and it is not creating that file. I have tried to find wt option would create the files in the options of visual studio and have found nothing. Should I just uninstall and reinstall it or are there any other thoughts. And yes I have the current updates for it, I just updated last night before I posted this and it still did it.


----------



## Ent (Apr 11, 2009)

I'm using VB.net instead of C#, so it may just be different,
For me the executable would be found in 
...\HelloWorld\HelloWorld\bin\Debug.

It may be worth checking whether you get that.

Also, a search *.exe wouldn't be amiss. 

I'll try to install C# and see if I can figure anything else out.

Edit: I mean C++. Sorry.
Second edit: And it won't install.


----------



## SpectresShadow (Aug 3, 2012)

I have all three visual studio express editions; VB, C++, and C#. Hardly use C# right now, but VB works fine. C++ was working fine 3 months ago, and aside from some windows 7 themes, command and conquer tiberian sun, and DX studio (for a project I am working on with friends, a new mmorpg that is done in the style of classic snes games for looks) I haven't installed anything new on my computer in that time.


----------



## Ent (Apr 11, 2009)

3 months! Do you know how many computers a geek can break in that time? 

It may seem like a stupid question, but are you actually building the program? 
As a VB programmer I'm used to just hitting F5 to compile and run, but if (?) I understand correctly for C++ you have to hit F7 first to build. If nothing else, it may be worth building it without executing it to see whether the problem kicks in there. It would make a lot of sense that it can't find the program because the program isn't there.


----------



## SpectresShadow (Aug 3, 2012)

Yes I do realize that 3 months is a long time but I had other priorities than to tinker with c++ in those 3 months, such as a job, job hunting, and the game that we are working on, which is primarily realbasic. I've never had to build the program before, while I was at the tech I just had to hit F5 to compile and run just like in vb.


----------



## Ent (Apr 11, 2009)

OK, C++ is working on my machine now, so I'll have a bit of a tinker and see what I can find. 
Apparently it's a fairly common problem.

http://forum.codecall.net/topic/60772-beginner-in-chow-to-compile-using-visual-studio-2010-express/
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/3d841d77-2cb9-4009-9d62-b7f8d7a060ce/


----------



## SpectresShadow (Aug 3, 2012)

I just noticed that silverlight is no longer on my computer for some reason. Would that have anything to do with it maybe?


----------



## Ent (Apr 11, 2009)

It could do, but I wouldn't have thought so.
What kind of project is this HelloWorld? 

The CLR Console project that the VC++ generates works fine if you just hit F5
Whereas as the empty one gives the exact same error message as you report.

Once I add a .cpp file with your source however, it compiles and works without a problem.


----------



## Ent (Apr 11, 2009)

Also, I notice that there's a "not saved" asterisk by source1.cpp
I wonder whether that may be a significant clue. I thought that the environment automatically saves the file before compilation. Is there something strange about where the source file is located for example?


----------



## SpectresShadow (Aug 3, 2012)

I checked all the options for that not saved asterisk and all that would do anything about it were set to save. What I did was open a new empty project, File, Open, File, and then typed the source. It worked that way all through the time at the tech. And that was the way I was told I am supposed to create a new project.


----------



## Ent (Apr 11, 2009)

What file did you open?

If you want to create a new project you need the files involved to be part of that project. Better would be to create a new file from within the project.
Right Click on the project (HelloWorld) in the Solution Explorer
Click on ADD then on New Item
Create CPP file.

It should automatically appear under Source files.

Then type your source.


----------



## Ent (Apr 11, 2009)

I have to sign off for the night; if that doesn't crack the problem I'll check back in the morning.


----------



## SpectresShadow (Aug 3, 2012)

Oops. I meant File, New, File, .cpp file. Sorry.


----------



## SpectresShadow (Aug 3, 2012)

Thank you for the help Ent. I was going about it all wrong. I have to remember to tinker with every language I know at least once or twice a month so that this doesn't happen again. The reason I wasn't doing the right click on the project in the solution explorer was because it was missing from my screen for some reason. That did the trick. Got to remember don't do file add new file. Just use the right click. Marking as solved.


----------

