• ### Announcements

#### Archived

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

# output

## Recommended Posts

I got dev c++ running and i tested it using the hello world program. Everthing was fine,but it didnt say"Hello World" And it wont give any cout outputs.

##### Share on other sites
Are you sure about that? I think you''re mistaking something else for getting no output. What exactly are you doing? What exactly is happening?

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

##### Share on other sites
Yeah. This is a common problem. The accepted solution is as follows:

  #include ... //and later, right before you return 0...system("PAUSE");

e-mail me if you need more help.

Later,
ZE.

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

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

##### 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 on other sites
quote:
Original post by ZealousElixir
Yeah. This is a common problem. The accepted solution is as follows:

  #include ... //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 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.//

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

##### Share on other sites
I always prefered double cin.get(); to clear the input buffer and wiat for a key:
  int main(){//some code herecin.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 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 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.//

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

##### Share on other sites
try adding ,#include <conio.h>, at the top
and then ,getch()!!! it helps!!
to close the window press enter!!!

##### Share on other sites
I don''t think getch() is ANSI-standard, but then again, neither is system().

Later,
ZE.

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

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

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627661
• Total Posts
2978496

• 10
• 12
• 22
• 13
• 33