output

Started by
10 comments, last by StoNeD_TrOLL 22 years, 2 months ago
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.
Advertisement
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?

Perhaps the console window is closing immediately after opening. Try putting a getch() at the end of your program.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Yeah. This is a common problem. The accepted solution is as follows:

  #include <stdlib.h>... //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.//
miscellaneous links

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

[twitter]warrenm[/twitter]

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
"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
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
"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
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.]

[twitter]warrenm[/twitter]

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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
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
"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
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.]

[twitter]warrenm[/twitter]

This topic is closed to new replies.

Advertisement