Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to clear a char variable

Reply
Thread Tools

How to clear a char variable

 
 
Azteka77 Azteka77 is offline
Junior Member
Join Date: Mar 2011
Posts: 1
 
      03-08-2011
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:

ImageBarcode:C123S025 (1st time)

ImageBarcode:C123S025C123R137 (2nd time)

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

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

Any Idea?

TIA
KR
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
The difference between char a[6] and char *p=new char[6] ? wwj C Programming 24 11-07-2003 05:27 PM
the difference between char a[6] and char *p=new char[6] . wwj C++ 7 11-05-2003 12:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57