Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Knight move, right direction, dynamic programming to get the maximum cost path from top left to right bottom. Pin
Richard MacCutchan26-Dec-19 4:25
mveRichard MacCutchan26-Dec-19 4:25 
QuestionIRichEditOle::InsertObject shifts text one byte Pin
ForNow21-Dec-19 18:18
ForNow21-Dec-19 18:18 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan21-Dec-19 22:07
mveRichard MacCutchan21-Dec-19 22:07 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow22-Dec-19 5:09
ForNow22-Dec-19 5:09 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan22-Dec-19 22:20
mveRichard MacCutchan22-Dec-19 22:20 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow23-Dec-19 1:04
ForNow23-Dec-19 1:04 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan23-Dec-19 2:03
mveRichard MacCutchan23-Dec-19 2:03 
QuestionCASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Vaclav_21-Dec-19 10:13
Vaclav_21-Dec-19 10:13 
CASE SOLVED AND CLOSED
FYI
As I pointed out in my recent post, which apparently did no good, this has been brought up before.
I am guilty of not going back to the original post.
Being repeatedly told that I am not sharing my code is getting old.
So - no need to be bothered again , let's just chalk this for yet another loop-sided discussion blaming the problem on me.

Cheers

CASE CLOSED



Re: Unexpected sequence of cout / perror in console output - C / C++ / MFC Discussion Boards[^]








SOLVED

It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full.








This is NOT a dupe, just an attempt to analyse / concentrate on specific problem.
The attached code execution clearly shows that the code is NOT run in sequence coded.
See line numbers - they are OUT of sequence.
The lines start with 40 and end with line 49

This is superficial, but annoying problem I would like to resolve.
Or just identify the reason for this behaviour.
BTW - inserting sleep(1) at various places "solves the problem".

cerr is used to output (stderr) to console in red AND WORKS just fine.


Maybe cerr and cout have conflicting "priority" or "4 core processor " in use is an issue.




C++
cout << " START test area " << __LINE__ << endl;
cout << " START test area " << __LINE__ << endl;
cerr << "Function: " << __FUNCTION__ << " @line " << dec << __LINE__
        << endl;
//sleep(1);
//int i = 0;
cerr << "TRACE TEST Function: " << __FUNCTION__ << " @line " << dec
        << __LINE__ << endl;
cout << "\tEND test area " << __LINE__ << endl;
cout << "\tEND test area " << __LINE__ << endl;





 START test area 40
 START test area 41
Function: 	END test area 48
	END test area 49
main @line 42
TRACE TEST Function: main @line 47


modified 22-Dec-19 9:44am.

AnswerRe: SOLVED cout and cerr execute out of coded sequence Pin
Richard MacCutchan21-Dec-19 21:32
mveRichard MacCutchan21-Dec-19 21:32 
AnswerRe: CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Richard MacCutchan22-Dec-19 22:55
mveRichard MacCutchan22-Dec-19 22:55 
QuestionSOLVED CASE CLOSED cout in color and perror - revisited Pin
Vaclav_20-Dec-19 4:46
Vaclav_20-Dec-19 4:46 
AnswerRe: cout in color and perror - revisited Pin
leon de boer20-Dec-19 5:01
leon de boer20-Dec-19 5:01 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_20-Dec-19 5:48
Vaclav_20-Dec-19 5:48 
AnswerRe: cout in color and perror - revisited Pin
Richard MacCutchan20-Dec-19 6:07
mveRichard MacCutchan20-Dec-19 6:07 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 3:10
Vaclav_21-Dec-19 3:10 
GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 3:34
mveRichard MacCutchan21-Dec-19 3:34 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 9:05
Vaclav_21-Dec-19 9:05 
GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 21:25
mveRichard MacCutchan21-Dec-19 21:25 
QuestionHow to close file in C++? Pin
Vaclav_19-Dec-19 17:13
Vaclav_19-Dec-19 17:13 
QuestionRe: How to close file in C++? Pin
CPallini19-Dec-19 21:35
mveCPallini19-Dec-19 21:35 
AnswerRe: How to close file in C++? Pin
Stefan_Lang19-Dec-19 21:59
Stefan_Lang19-Dec-19 21:59 
AnswerRe: How to close file in C++? Pin
Vaclav_20-Dec-19 4:51
Vaclav_20-Dec-19 4:51 
AnswerRe: How to close file in C++? Pin
Richard MacCutchan19-Dec-19 21:56
mveRichard MacCutchan19-Dec-19 21:56 
QuestionDo "setw(offset) " BEFORE cout ? Pin
Vaclav_18-Dec-19 4:22
Vaclav_18-Dec-19 4:22 
AnswerRe: Do "setw(offset) " BEFORE cout ? Pin
Richard MacCutchan18-Dec-19 4:56
mveRichard MacCutchan18-Dec-19 4:56 

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.