Clear buffer

This is a discussion on Clear buffer within the C++ Programming forums, part of the General Programming Boards category; How can I clear the buffer, it is a char variable of unknown size and I want to get all ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    8

    Clear buffer

    How can I clear the buffer, it is a char variable of unknown size and I want to get all the existing data out, how?

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Buffer?
    And a char variable can only hold a letter.
    You mean you have a pointer or an array?

    if pointer:

    pointer = NULL;

    if array:

    for(int i = 0; array[i]!="\0"; i++) {
    array[i] = "";
    }

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    8
    Lemme retry.

    char dude[500] = "hello there, yes i know i'm cool";

    now I want to make the variable of type char NULL, or have nothing in it.

    char dude[500] = ""; // no data in it now...

  4. #4
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Just asking.... why?

    Well anyways, use my method:

    for(int i = 0; dude[i]!="\0"; i++) {
    dude[i] = "";
    }

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    memset ( dude, '\0', 500 );

    -Prelude
    My best code is written with the delete key.

  6. #6
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Well thats _one_ way

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    8
    ErionD, I did'nt mess with your method much but it did'nt compile unlike Preludes.

    I'm setting text in an edit control and if the buffer is'nt empty, it messes up.

    Thanks for the help & concern.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithreading (flag stopping a thread, ring buffer) volatile
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 05-19-2009, 07:27 AM
  2. Frame buffer not working
    By Noise in forum Game Programming
    Replies: 1
    Last Post: 02-15-2009, 11:05 AM
  3. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  4. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 08:09 PM
  5. Having Buffer Problems With Overlapped I/O --
    By Sargera in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 03:46 PM

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