How to clear a char variable

Discussion in 'C Programming' started by Azteka77, Mar 8, 2011.

  1. Azteka77

    Azteka77

    Joined:
    Mar 8, 2011
    Messages:
    1
    Hi,

    Do you know how can I clear a Char Variable?
    I'm using label var to receive a SerNum from a Barcode reader, then I use strcat to apend this value to another var that later I use to log the result for a Test as follows.

    char barcode[15];
    char label[15];
    char ImageBarcode[23] = {"ImageBarcode:"};
    .
    ....
    read_barcode2(bar_label_path, 11);
    strcpy(label,barcode);
    strcat(ImageBarcode,barcode);

    Then using fopen, I create a TXT file with some data, using fputs.
    at first run all is Ok but at 2nd time, the line for imagebarcode showed something like this::sheep

    ImageBarcode:C123S025 (1st time)

    ImageBarcode:C123S025C123R137 (2nd time)

    I tried to clear my var using this
    ImageBarcode = "";
    ImageBarcode[23] = "";
    ImageBarcode = "\0";

    And nothing :bawling:, I got an error like invalid conversion char * to const char *.

    Any Idea?

    TIA
    KR
    Azteka77, Mar 8, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wwj
    Replies:
    7
    Views:
    527
  2. wwj
    Replies:
    24
    Views:
    2,462
    Mike Wahler
    Nov 7, 2003
  3. lovecreatesbeauty
    Replies:
    1
    Views:
    995
    Ian Collins
    May 9, 2006
  4. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    991
    Mark Fitzpatrick
    Jan 31, 2008
  5. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    917
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page