Archived

This topic is now archived and is closed to further replies.

StoNeD_TrOLL

output

Recommended Posts

Perhaps the console window is closing immediately after opening. Try putting a getch() at the end of your program.

Share this post


Link to post
Share on other sites
You have to be more specific. For instance, it could be because you don''t see any window. In that case:
Check your code for bugs (doubtful)
Make sure to add getch() at the end (so the window doesn''t close right away)
umm....

If all you did was a simple
cout << "Hello World!"; 
then the problem lies in flushing the buffer (You''ll understand this later, for now just add an endl to the end. Or you could do it one of these ways
  
cout << "Hello World!";
cin >> anything;//This flushes the input onto the screen, but then you have to input something...


cout << "Hello World!" << endl;//This flushes the buffer...but then it ends the line...what if we don''t want that?


cout << "Hello World!" << flush;//Ahh...perfect



"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin

Share this post


Link to post
Share on other sites
quote:
Original post by ZealousElixir
Yeah. This is a common problem. The accepted solution is as follows:


    
#include <stdlib.h>

... //and later, right before you return 0...


system("PAUSE");

.
.
.


You shouldn''t use System() statements, if at all avoidable (Although I usually do, it error-prone, so you should find other ways to do it. getch() is easy enough that you don''t need system...now copy-ing & ren-ing files....)

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin

Share this post


Link to post
Share on other sites
system() calls are not error-prone. I don''t know where you heard that, but any Windows platform supports them perfectly, so don''t spout your I-heard-this-so-it''s-true crap at me until you know what you''re talking about.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
I always prefered double cin.get(); to clear the input buffer and wiat for a key:
  
int main()
{
//some code here

cin.get();
cin.get();
}


-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Democracy is where you say what you want and do what you''re told.

Share this post


Link to post
Share on other sites
quote:
Original post by ZealousElixir
system() calls are not error-prone. I don''t know where you heard that, but any Windows platform supports them perfectly, so don''t spout your I-heard-this-so-it''s-true crap at me until you know what you''re talking about.



It is error prone.
System("ren aaa.txt bbb.txt");
If there was no aaa.txt, the program will continue, assuming that there WAS a aaa.txt, and that there IS a bbb.txt. ASSUMING

same goes with copy (not to mention if you COPY from the keyboard, its not very user-friendly - you have to hit F6 to exit if I remember correctly....I''m not sure though)

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin

Share this post


Link to post
Share on other sites
Why are we discussing copy and rename? The point is that system("PAUSE") has no adverse effects now or in the foreseeable future (that is, until all console emulation is removed, and probably not even then). Therefore, (and I was wrong to speak so harshly in general terms about the system() function) I see no reason to not use it.

No offense, and I''m glad you''re so good-natured ,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites