how to know that the buffer is not clean??

This is a discussion on how to know that the buffer is not clean?? within the C Programming forums, part of the General Programming Boards category; after i do scanf i want to check if the buffer is clean how to know that the buffer is ...

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    how to know that the buffer is not clean??

    after i do scanf i want to check if the buffer is clean

    how to know that the buffer is not clean??

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Give it a sniff!

    Seriously, tho, you will be much happier with life if you write 'lil fgetc() or read() functions like me
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by transgalactic2 View Post
    after i do scanf i want to check if the buffer is clean

    how to know that the buffer is not clean??
    are you scanning the input into the buffer? not sure what you mean exactly by "after i do scanf i want to check if the buffer is clean..."

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    61
    dosent scanf by definition take all chars from input buffer and transfer to the buffer inside your program?

    hangon which buffer??? the terminal or your C buffer???

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Quote Originally Posted by davo666 View Post
    dosent scanf by definition take all chars from input buffer and transfer to the buffer inside your program?
    No. It doesn't transfer anything, it converts the input characters according to the conversion specifiers. Characters which are converted are removed from the buffer. If a conversion fails, the characters which did not convert REMAIN in the buffer.

    And we are talking about the stdio buffer, not the terminal buffer.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    use fgets/sscanf pair
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  2. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 08:09 PM
  3. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 02:34 PM
  4. clean out a buffer
    By threahdead in forum C Programming
    Replies: 8
    Last Post: 02-23-2003, 12:04 PM
  5. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 04:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21