Well, C++ freezes somehow after compiling i run the program and....

http://pastebin.com/AP0eUNes

it freezes at line 146.
If I add a line before that that couts something it still does that Lade Vokabelkästen... but then freezes. It never draws the smiley, even if i comment out everything in the main function before that smiley, it still freezes. Please help me!
std::endl is more than an end-of-line - it also flushes the buffer that you are writing to. For performance reasons data is often held temporarily in a buffer before being sent to the screen or to disk and then sent to the target device in one large chunk (either when the buffer is full or is explicitly flushed). Therefore you should make sure you either call flush or use std::endl after writing data to the screen (or to file) that you want to make sure the user can see.
Ah, thanks, that solved everything, I din't knew that.
why does then stuff like this work?

Code:
cout << "Input:";
cin >> temp;
Because there the line doesn't end as-well.
It works because reading from std::cin implicitly flushes std::cout (at least, that is my understanding). Even if you never flushed the buffer there would still likely be occasions when the content appeared on screen (e.g. if the buffer is full).
And in general, if you want to analyze what's going wrong, you should set breakpoints, fire up a debugger, and step through your code.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement