Link to home
Start Free TrialLog in
Avatar of Ohrasta
Ohrasta

asked on

Visual Studio 2003 C++ console application console error

I have visual studio 2003 and I am creating a console application under C++. Upon running I can not get my console to correctly work correctly. The console box appears but nothing is visble and no cout statements or cin statements seem to be working. Why?

I already had a 'Test fatal error LNK1201: error writing to program database' error and that problem was solved by disable the 'Microsoft Windows Defender' service. (Anti-spyware). Would there any kind of security program or setting that would stop VS from using the console correctly?

Just for sake I am including the code written.

#include "stdafx.h"
using namespace std;

int main()
{
      cout << "Test" << endl;
      return 0;
}


no text saying "Test" are ever printed, instead the console window shows up and the application stops responding. Clicking the X will reward in an end task dialog.
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

You need to set a breakpoint to 'return 0;' or change to

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
     cout << "Test" << endl;
     int i;
     cin >> i;
     return 0;
}

Regards, Alex
ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ohrasta
Ohrasta

ASKER

Actually it was a dumb mistake on my behalf. I was choosing console application instead of Win32 Console application. However, itsmeandnobdodyelse has the right idea, points awarded to him.