Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence

CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++asp-netcomdebugging
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    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

    L 2 Replies Last reply
    0
    • V Vaclav_

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I still cannot get the output in the "wrong" order. As mentioned below, I think there is a key piece of information that you have not shared with us.

      1 Reply Last reply
      0
      • V Vaclav_

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Vaclav_ wrote:

        Being repeatedly told that I am not sharing my code is getting old.

        And there is an easy way to prevent that ...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups