![]() |
|
#1
|
|||
|
|||
printf won't display output until my program terminatesMy program operates as I would expect, with one iritating exception. I wanted to have a sort of status bar displayed
so that I could see what kind of progress was being made; however, when I execute the program the status bar isn't displayed, that is until the program terminates, at which point it prints the whole thing at once. CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
Re: printf won't display output until my program terminatesEvery time you output the status bar info, add fflush(stdout); and see what happens. You may have to flush the output buffer to get the display properly.
__________________
Age is unimportant -- except in cheese |
|
#3
|
|||
|
|||
Re: printf won't display output until my program terminatesThank you so much WaltP, your suggestion worked perfectly.
Cheers, JonK |
|
#4
|
||||
|
||||
Re: printf won't display output until my program terminatesAhh, good. Output in some compilers is buffered, so it waits until the buffer is full before displaying the informatin. fflush() tells the program to output the stuff now, don't wait.
__________________
Age is unimportant -- except in cheese |
|
#5
|
|||
|
|||
Re: printf won't display output until my program terminatesThat seems counterintuitive to me, although I haven't the faintest notion of how a computer works, or why languages are constructed the way they are. I suppose if I want to continue using C, I should take the time to learn a little about both. Anyhow, your suggestion was a big help to me; I'd likely not have discovered that little tidbit for days if I had to figure it out on my own.
Thanks |
Recent GIDBlog
Toyota - 2008 September Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating a file in [c] | i hate c | C Programming Language | 15 | 21-Nov-2005 12:52 |
| My program can run,but warning were display on Vc++ | fwongmc | C Programming Language | 5 | 08-Dec-2004 10:15 |
| RSA program | fwongmc | C Programming Language | 11 | 08-Nov-2004 22:15 |
| problem with the program under Borland | awmp-jansen | C Programming Language | 3 | 01-Jul-2004 17:05 |
| using vector or array | oshiotse | C++ Forum | 4 | 16-Apr-2004 10:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The