Thread: concept of buffering in c

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    concept of buffering in c

    i came to know about this concept from a random program from a random blog: Disemble
    i am sending the program as attachment.

    Code:
    This program will not print "hello-out". Find out the problem.
    
    
    
    #include <stdio.h>
    
      #include <unistd.h>
    
      int main()
    
      {
    
              while(1)
    
              {
    
                      fprintf(stdout,"hello-out");
    
                      fprintf(stderr,"hello-err");
    
                      sleep(1);
    
              }
    
              return 0;
    
      }
    Attached Files Attached Files
    Last edited by Salem; 06-08-2011 at 12:57 PM. Reason: Inlining the attachment

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Great story, kid. Is there a question in there somewhere? Why don't you post your code in code tags, like a normal person. Some of us are hesitant to download strange files from strange people. Also, make sure you've covered the required reading:
    Announcements - C Programming
    and the supplemental stuff:
    How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Question 11.17

    Edit: What! the link and code are not the same....
    stdout is usually line buffered while stderr is not. You can set buffering mode using setvbuf(). or use flush().
    The rest is RTFM.
    Last edited by Bayint Naung; 06-08-2011 at 12:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I do double buffering in console?
    By pliang in forum Game Programming
    Replies: 17
    Last Post: 04-20-2005, 07:19 AM
  2. Double Buffering in mode 12h
    By j0seph in forum C Programming
    Replies: 6
    Last Post: 03-04-2005, 12:09 AM
  3. Buffering??
    By Brain Cell in forum C Programming
    Replies: 15
    Last Post: 09-21-2004, 06:57 AM
  4. Can anyone explain to me what buffering is?
    By Neildadon in forum C Programming
    Replies: 4
    Last Post: 06-12-2002, 08:20 AM
  5. double buffering in MFC
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 03-07-2002, 12:29 PM