Re: Read hex string to a buf
- From: Christopher Layne <clayne@xxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 06:22:57 -0800
CBFalconer wrote:
$ cc -g3 -O3 -W -Wall -Werror -pedantic -o hex2dec hex2dec.c
cc1: warnings being treated as errors
hex2dec.c: In function 'main':
hex2dec.c:25: warning: array subscript has type 'char'
hex2dec.c:26: warning: array subscript has type 'char'
hex2dec.c:38: warning: array subscript has type 'char'
hex2dec.c:39: warning: array subscript has type 'char'
Yup. It's talking about set, and pointing out your error. Try
defining set as either signed or unsigned char. As usual, a cast
is probably an error.
Hah, you guys. We've hashed the angles about 4 different ways :).
Either way, something will be cast. If it's not the array indices, it's
strlen() and/or assigment from argv[1] to q.
(I haven't really looked at most of your program; a couple of
things just jumped out at me.)
Good ole comp.lang.c. Quick to point out any error. Care to add
anything else?
Yup. Wrong specification for printing an uncast size_t in your
printf statement. Here you have a real reason for using a cast, at
least in C90.
You're right on that one - and I usually cast to unsigned long and use "%lu",
it just so coincidentally happened that I didn't use "%lu", and on my
host "%u" results in no warnings.
.
- Follow-Ups:
- Re: Read hex string to a buf
- From: CBFalconer
- Re: Read hex string to a buf
- References:
- Read hex string to a buf
- From: cppbeginner
- Re: Read hex string to a buf
- From: Christopher Layne
- Re: Read hex string to a buf
- From: Keith Thompson
- Re: Read hex string to a buf
- From: Christopher Layne
- Re: Read hex string to a buf
- From: CBFalconer
- Read hex string to a buf
- Prev by Date: Re: How to improve this sort?
- Next by Date: Re: check if the memory is low, from Windows to Unix
- Previous by thread: Re: Read hex string to a buf
- Next by thread: Re: Read hex string to a buf
- Index(es):
Relevant Pages
|