星期二, 十二月 20, 2005

if or if-else?

In Crafty:

int OptionMatch(char *command, char *input){
/* ************************************************************ * * * check for the obvious exact match first. * * * ************************************************************ */
if (!strcmp(command, input))
return (1);
/* ************************************************************ * *
* now use strstr() to see if "input" is in "command." *
* the first requirement is that input matches command *
* starting at the very left-most character; * * * ************************************************************ */
if (strstr(command, input) == command)
return (1);
return (0);
}

It seems better to use "if " than "if-else" if it returns in the statement...

没有评论: