Re: Comparing string input to enum data type
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Wed, 28 Feb 2007 04:02:49 -0500
Yevgen Muntyan wrote:
Nelu wrote:
Yevgen Muntyan wrote:
CBFalconer wrote:
Yevgen Muntyan wrote:
Bill Pursell wrote:... snip ...
If you've red the string into a, and you want to set c:
if( 0 == strncmp("red", a, sizeof "red") )
c = red;
else if ...
Funny thing it actually works since 'sizeof "red"' is
greater than length of "red". Still, a rather strange
way to compare strings.
sizeof "red" had better be 4.
What do you mean? It doesn't matter if it's 4 or 15, as long
as it's greater than 3 (and it is).
sizeof "red" must be 4 no matter where you run the program. It
should give you the length of the array holding the string.
I say it 'sizeof "red" *is* 4', so I don't understand 'sizeof
"red" had better be 4'.
It's an English idiom, meaning that if sizeof "red" isn't 4
something is seriously wrong.
I restored the blank separator lines your software mistakenly
removed.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
.
- Follow-Ups:
- Re: Comparing string input to enum data type
- From: dtschoepe@xxxxxxxxx
- Re: Comparing string input to enum data type
- References:
- Comparing string input to enum data type
- From: dtschoepe@xxxxxxxxx
- Re: Comparing string input to enum data type
- From: Bill Pursell
- Re: Comparing string input to enum data type
- From: Yevgen Muntyan
- Re: Comparing string input to enum data type
- From: CBFalconer
- Re: Comparing string input to enum data type
- From: Yevgen Muntyan
- Re: Comparing string input to enum data type
- From: Nelu
- Re: Comparing string input to enum data type
- From: Yevgen Muntyan
- Comparing string input to enum data type
- Prev by Date: Re: pointer initialization
- Next by Date: Re: pointer representation: style or substance?
- Previous by thread: Re: Comparing string input to enum data type
- Next by thread: Re: Comparing string input to enum data type
- Index(es):
Relevant Pages
|