Thread: flush stdout?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    32

    flush stdout?

    hi

    is there a way to flush stdout before calling printf?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Code:
    fflush(stdout);

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    32
    ah ok pretty straight forward thanks mate

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    Just curios - why do you need it BEFORE printf?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    32
    not exactly before printf... i said before printf to make the question more understandable for what i'm trying to do...

    But what happened was that from after a fork i was calling a function, where while this function was getting executed before getting ready to print, the caller of the function was waiting on a signal to print a long stream, where when the child prints his stuff(before sending the signal it was getting mixed with the stuff of the caller which i didn't want to show yet.... Anyway tried to explain it... but it worked now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 08:46 PM
  2. Replies: 2
    Last Post: 07-12-2008, 12:00 PM
  3. forcing stdout of external program to be line-buffered
    By FreakCERS in forum C Programming
    Replies: 4
    Last Post: 09-17-2006, 12:46 PM
  4. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM
  5. How do I print a pattern flush right?
    By Basia in forum C Programming
    Replies: 5
    Last Post: 06-11-2002, 07:15 AM