Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ printing in a loop

Name: Anonymous 2012-07-05 17:14

Hello!
Does anyone know how to tell the program to print stuff each single step in my loop?
Whenever i execute the program it just prints the very last step:

  for( uint i = 0; i < iter; i++) {
    [...]
    std::cout << "stuff";
  }

Thanks!

Name: Anonymous 2012-07-05 17:18

Maybe i wasn't clear: I want to let the program print stuff every step but it only prints *all* steps at the end.

Name: Anonymous 2012-07-05 17:21

>>2
Put a << std::endl after "stuff".

Name: Anonymous 2012-07-05 17:24

cout, cin, fstream, ostream
harmful, use printf

Name: Anonymous 2012-07-05 17:34

>>3 is probably right. This sounds like an unflushed1 buffer issue.

>>4
printf is ridiculously slow. I wish compilers would optimise it instead of having the run-time library decode the format string.

__________
1. TODO: Insert toilet joke.

Name: Anonymous 2012-07-05 17:46

>>5
fputs

Name: Anonymous 2012-07-05 18:07

>>5
The format string may be dependent on program state.

Name: bampu pantsu 2012-07-06 4:57

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List