More C programming questions ...
Roger Oberholtzer
roger
Thu Feb 17 15:02:08 PST 2005
On Tue, 2005-02-15 at 12:47 -0600, Rick Sivernell wrote:
> All
>
> > > for (idx = 0 ; idx < numberitems ; idx++ )
> {
> gogetmydata( string ) ;
> if (! strncmp( string, "ITEMID", 6) ) // less work for the compiler & typing
Less typing, but less obvious. If you read this, it would be 'if not
strncmp...)', when what you really mean is 'if strncmp() says strings
match'. Which For understandable maintainable code, I, personally, would
do:
#Define STRINGS_MATCH 0 // Maybe in an #include file I use all
// the time
If ( strncmp( string, "ITEMID", 6) == STRINGS_MATCH) { whatever }
Granted this is a common function that would not confuse a programmer.
But when the functions become less common, this is, IMHO, much better.
All a matter of taste.
--
Roger Oberholtzer <roger at opq.se>
More information about the Linux-users
mailing list