Re: Comparing string input to enum data type
- From: "Bill Pursell" <bill.pursell@xxxxxxxxx>
- Date: 28 Feb 2007 10:35:53 -0800
On Feb 27, 10:17 pm, Keith Thompson <k...@xxxxxxx> wrote:
"Bill Pursell" <bill.purs...@xxxxxxxxx> writes:
if( 0 == strncmp("red", a, sizeof "red") )
c = red;
else if ...
Why not just strcmp("red", a)?
Just a general tendency to refrain from using
strcmp. In this case, since one of the strings is
fixed, there's no security issue with strcmp (until
the code maintainer modifies the code...),
but I believe it's a good habit to use the strncmp
variant.
.
- Follow-Ups:
- Re: Comparing string input to enum data type
- From: Keith Thompson
- Re: Comparing string input to enum data type
- From: Ben Pfaff
- 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: Keith Thompson
- Comparing string input to enum data type
- Prev by Date: Re: Comparing string input to enum data type
- Next by Date: Re: Redirecting stderr
- Previous by thread: Re: Comparing string input to enum data type
- Next by thread: Re: Comparing string input to enum data type
- Index(es):