Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output not showing up. What am i doing wrong?

Status
Not open for further replies.

mstrdrgn1012

Programmer
Nov 11, 2004
8
US
ok. so i have this .cpp file, and i just want to execute it...
so i build it, then i execute it, and i get the lil black window to pop up then immediately disapear. and im using an input stream, so it SHOULD stop and let the user input something...but doesnt. I used getch() too just to see if it helped, but to no avail.
 
Try using:
Code:
system( "pause" );
That should at least stop the window from disappearing right away. If not, then there might be an exception being thrown somewhere.
 
whats an exception??

anyway, i cant even get this to work:

#include <iostream>

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


note that thats not my program. i know its probably some ridiculous thing im not doing right but i cant get it to work....i type my stuff, then F7, then F5. and nothing....
 
If you could list your source code that might help as well. But from the looks of things, if your iclude statement is similar to the one above - you need to add '.h' after iostream otherwise 'cout' will be an undeclared identifier. Also, and exception is basically an error code when recognized by program performs some specific error response (eg. error message, execution break, etc.).
 
IBey said:
you need to add '.h' after iostream otherwise 'cout' will be an undeclared identifier.
No, don't add the '.h' to iostream. <iostream.h> is an old, non-standard header that isn't even supported by the VC++ .NET 2003 compiler. Instead, use <iostream> and add "using namespace std;" under the include to get it to compile.


You can add cin.get(); as the last line of the main function to get the console window to stay up. The getch() function should also work, as would system("pause"). If they aren't working, you should show your code to see what is going wrong.
 
Don't forget to ask the obvious...
Are you working in .Net environment?
Is your project a Win32 Console Application?
 
its a .cpp source file in a win32 project.

heres a sample code that i tried and got me same results.

#include <iostream>
using namespace std;

int main()
{
int test;

cout<<"test";
cin>>test;
cout<<test;
return 0;
}

now that should print somethin up and promt me to input somethin..........but it doesnt.

im using the 2005 express beta version available for download.

does anybody know where i can download studio 6 for free?!?!? would really really really help.....VC++ 6.0, i know how to use.

 
There is nothing wrong with the code you posted. It might be a beta bug?
Try compiling the program, then instead of running it from Visual Studio, go to a command prompt and run it there. That way the window won't disappear and you can see what kind of output you get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top