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
    Likes Received:
    0
    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. Advertisements

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:
    793
  2. wwj
    Replies:
    24
    Views:
    2,916
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    699
    Tristan Miller
    Jan 17, 2004
  4. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    831
    Jack Klein
    May 9, 2005
  5. kevin.hall@motioneng.com
    Replies:
    24
    Views:
    1,237
    Netocrat
    Oct 30, 2005
  6. lovecreatesbeauty
    Replies:
    1
    Views:
    1,409
    Ian Collins
    May 9, 2006
  7. gert
    Replies:
    20
    Views:
    1,547
  8. aldonnelley@gmail.com
    Replies:
    3
    Views:
    965
    aldonnelley@gmail.com
    Apr 20, 2006
Loading...