Computing.Net > Forums > Programming > C++ .net cout not working?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ .net cout not working?

Reply to Message Icon

Name: sabre252
Date: December 16, 2004 at 18:27:05 Pacific
OS: Windows XP Pro
CPU/Ram: 512mb
Comment:

hi everyone, I have just installed Visual Studio .net, and typed in a basic program (see below) using cout, when I run my program however, I get a blank box with nothing in it! where did my string go??

#include <iostream>
using namespace std;
int main() {

cout << "Hello, World!" << endl;

return 0;

}

-- where did my cout go?!

thanks for the help!



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: December 16, 2004 at 20:03:37 Pacific
Reply:

I'm sure that what you get is a console window that pops up and disappears so fast that you can't see what's in it. When you run a console program from the IDE, it opens a console box for the program to run in and the console box closes as soon as the program is done.

If you were to run your program from a command line, you'd see the output. Another option is to add an input line (fgets(), getchar(), etc) after the cout. This will cause the program to stop for some input, so you see the output.

Be sure to come back and let us know if our suggestions helped!


0

Response Number 2
Name: sabre252
Date: December 16, 2004 at 21:28:51 Pacific
Reply:

thanks for the reply! that was indeed what I was seeing, I'll try the inclusion of that code asap.
i'll post as soon as I try it

-- Sabre
p.s. -- I never noticed this in prior versions of VS? ... ohh well I spent more time with VB..Thanks again!


0

Response Number 3
Name: Infinite Recursion
Date: December 17, 2004 at 12:18:27 Pacific
Reply:

"p.s. -- I never noticed this in prior versions of VS?"

Yes. I normally included stdlib.h and placed a system("PAUSE") in my code, but that seems to be frowned upon due to portability, etc.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ .net cout not working?

C++ 3.0 is not working over XP OS www.computing.net/answers/programming/c-30-is-not-working-over-xp-os/13290.html

eof() is missing in VS C++ NET 2003 www.computing.net/answers/programming/eof-is-missing-in-vs-c-net-2003/9931.html

visual studio.net not as good as b4 www.computing.net/answers/programming/visual-studionet-not-as-good-as-b4/1329.html