Click here to Skip to main content
14,457,040 members

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 5:25
communityengineerRichard MacCutchan26-Dec-19 5:25 
QuestionIRichEditOle::InsertObject shifts text one byte Pin
ForNow21-Dec-19 19:18
MemberForNow21-Dec-19 19:18 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan21-Dec-19 23:07
communityengineerRichard MacCutchan21-Dec-19 23:07 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow22-Dec-19 6:09
MemberForNow22-Dec-19 6:09 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan22-Dec-19 23:20
communityengineerRichard MacCutchan22-Dec-19 23:20 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
ForNow23-Dec-19 2:04
MemberForNow23-Dec-19 2:04 
GeneralRe: IRichEditOle::InsertObject shifts text one byte Pin
Richard MacCutchan23-Dec-19 3:03
communityengineerRichard MacCutchan23-Dec-19 3:03 
QuestionCASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Vaclav_21-Dec-19 11:13
MemberVaclav_21-Dec-19 11: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.




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 22:32
communityengineerRichard MacCutchan21-Dec-19 22:32 
AnswerRe: CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Richard MacCutchan22-Dec-19 23:55
communityengineerRichard MacCutchan22-Dec-19 23:55 
QuestionSOLVED CASE CLOSED cout in color and perror - revisited Pin
Vaclav_20-Dec-19 5:46
MemberVaclav_20-Dec-19 5:46 
AnswerRe: cout in color and perror - revisited Pin
leon de boer20-Dec-19 6:01
Memberleon de boer20-Dec-19 6:01 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_20-Dec-19 6:48
MemberVaclav_20-Dec-19 6:48 
AnswerRe: cout in color and perror - revisited Pin
Richard MacCutchan20-Dec-19 7:07
communityengineerRichard MacCutchan20-Dec-19 7:07 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 4:10
MemberVaclav_21-Dec-19 4:10 
GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 4:34
communityengineerRichard MacCutchan21-Dec-19 4:34 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 10:05
MemberVaclav_21-Dec-19 10:05 
GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 22:25
communityengineerRichard MacCutchan21-Dec-19 22:25 
QuestionHow to close file in C++? Pin
Vaclav_19-Dec-19 18:13
MemberVaclav_19-Dec-19 18:13 
QuestionRe: How to close file in C++? Pin
CPallini19-Dec-19 22:35
mveCPallini19-Dec-19 22:35 
AnswerRe: How to close file in C++? Pin
Stefan_Lang19-Dec-19 22:59
mveStefan_Lang19-Dec-19 22:59 
AnswerRe: How to close file in C++? Pin
Vaclav_20-Dec-19 5:51
MemberVaclav_20-Dec-19 5:51 
AnswerRe: How to close file in C++? Pin
Richard MacCutchan19-Dec-19 22:56
communityengineerRichard MacCutchan19-Dec-19 22:56 
QuestionDo "setw(offset) " BEFORE cout ? Pin
Vaclav_18-Dec-19 5:22
MemberVaclav_18-Dec-19 5:22 
AnswerRe: Do "setw(offset) " BEFORE cout ? Pin
Richard MacCutchan18-Dec-19 5:56
communityengineerRichard MacCutchan18-Dec-19 5: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.