Click here to Skip to main content
16,010,268 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: focus to the current instance of a program Pin
Flit30-May-05 6:59
Flit30-May-05 6:59 
Generalmosaïc background Pin
toxcct25-May-05 22:43
toxcct25-May-05 22:43 
GeneralRe: mosaïc background Pin
Iain Clarke, Warrior Programmer26-May-05 1:10
Iain Clarke, Warrior Programmer26-May-05 1:10 
GeneralRe: mosaïc background Pin
toxcct26-May-05 1:14
toxcct26-May-05 1:14 
Generala question about endl!!! Pin
ligerDave25-May-05 21:31
ligerDave25-May-05 21:31 
GeneralRe: a question about endl!!! Pin
Bob Stanneveld25-May-05 21:42
Bob Stanneveld25-May-05 21:42 
GeneralRe: a question about endl!!! Pin
ligerDave26-May-05 15:00
ligerDave26-May-05 15:00 
GeneralRe: a question about endl!!! Pin
Bob Stanneveld26-May-05 20:15
Bob Stanneveld26-May-05 20:15 
Thant depends on what you want. If you want that your output doesn't hang around in some buffer, use endl. If you can afford that your output doesn't become visible right away, use "\n".

Consider the following piece of code:
<br />
for( int i = 0; i < 1000; i++ )<br />
{<br />
// some heavy calculation<br />
std::cout << i << std::endl<br />
<< OtherOutput << std::endl;<br />
}<br />
std::cout << "Finished" << std::endl;<br />


The above code snippet is not very optimized. It has to wait for the ouput to flush all the data at every endl! So in this loop you take a great performance hit. The next code snippet is better:

for( int i = 0; i < 1000; i++ )
{
// some heavy calculation
std::cout << i << "\n"
<< OtherOutput << "\n";
}
std::cout << "Finished" << std::endl;


This code runs faster and it flushes the output buffer only when needed (when it's full) and when your calculation is finished.

Hope this helps Big Grin | :-D

Blog[^]
GeneralPicture Control Pin
daouner25-May-05 21:10
daouner25-May-05 21:10 
GeneralRe: Picture Control Pin
«_Superman_»25-May-05 22:04
professional«_Superman_»25-May-05 22:04 
GeneralRe: Picture Control Pin
daouner25-May-05 22:09
daouner25-May-05 22:09 
GeneralRe: Picture Control Pin
daouner26-May-05 7:57
daouner26-May-05 7:57 
GeneralRPC server startup Pin
Krishnan V25-May-05 20:48
Krishnan V25-May-05 20:48 
GeneralRe: RPC server startup Pin
Blake Miller26-May-05 3:34
Blake Miller26-May-05 3:34 
QuestionMFC version used ? Pin
toxcct25-May-05 20:39
toxcct25-May-05 20:39 
AnswerRe: MFC version used ? Pin
ThatsAlok25-May-05 20:54
ThatsAlok25-May-05 20:54 
GeneralRe: MFC version used ? Pin
toxcct25-May-05 20:58
toxcct25-May-05 20:58 
GeneralRe: MFC version used ? Pin
ThatsAlok25-May-05 21:08
ThatsAlok25-May-05 21:08 
GeneralRe: MFC version used ? Pin
toxcct25-May-05 21:16
toxcct25-May-05 21:16 
GeneralRe: MFC version used ? Pin
ThatsAlok25-May-05 21:21
ThatsAlok25-May-05 21:21 
GeneralRe: MFC version used ? Pin
ThatsAlok25-May-05 21:26
ThatsAlok25-May-05 21:26 
GeneralRe: MFC version used ? Pin
M. Wohlers26-May-05 6:33
M. Wohlers26-May-05 6:33 
GeneralRe: MFC version used ? Pin
ThatsAlok26-May-05 18:40
ThatsAlok26-May-05 18:40 
AnswerRe: MFC version used ? Pin
ddmcr25-May-05 21:28
ddmcr25-May-05 21:28 
GeneralRe: MFC version used ? Pin
toxcct25-May-05 21:42
toxcct25-May-05 21:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.