1.
正确代码:
for( word = strtok( buf, whitespace); word != NULL; word = strtok( NULL, whitespace)) { if (strcmp(word,"the" ) == 0 )
错误代码:
for( word = strtok( buf, whitespace); word != NULL; word = strtok( NULL, whitespace));{ if (strcmp(word,"the" ) == 0 )
错误原因: 由于多了个分号.所以for循环体中实际执行的代码是 ; 这行空语句, if语句则变成了循环体外,
所以在调用strcmp中,参数word将永远为NULL.