On Wed, May 16, 2007 at 08:45:04AM -0700, jerry gay wrote: > here's a macro to move to the next argument (kjs mentioned in an > earlier thread that this isn't a descriptive name) > > /* na(c) [Next Argument (Char pointer)] > * > * Moves the pointer to the next argument in the user input. > */ > #define na(c) { \ > while (*c && !isspace((int) *c)) \ > c++; \ > while (*c && isspace((int) *c)) \ > c++; }
That ought to be written (at least): #define na(c) { \ while (*c && !isspace((int) *c)) \ c++; \ while (isspace((int) *c)) \ c++; } because isspace('\0') is false And really, given that macros are text substitutions, standard practice is to wrap all arguments in parentheses, to avoid bugs related to precedence when something more complex is passed in. So, in general, I'd be happier with: #define na(c) { \ while (*(c) && !isspace((int) *(c))) \ (c)++; \ while (isspace((int) *(c))) \ (c)++; } Nicholas Clark