问题
When I try to compile my C program with cc I get a warning that I have an implicit function declaration isspace. Isn't this part of the standard C library? Which import do I need to do so my function runs properly?
Thanks a lot for your help!
Cheers
回答1:
You need #include <ctype.h>.
However make sure you read the documentation carefully. Its interface is unintuitive, for historical reasons.
It's designed to work only on a value from 0 to UCHAR_MAX (usually 255) -- the same sort of value that is returned by the getchar() function. For example:
int ch = getchar();
if ( isspace(ch) )
Do not use it with a char. If you have a char that you want to check for whitespace, it must be converted to be in the expected range; e.g. by a cast to (unsigned char):
char ch = 't';
if ( isspace( (unsigned char)ch ) )
The same goes for all of the other is* functions in ctype.h
回答2:
You need:
#include <ctype.h>
来源:https://stackoverflow.com/questions/28654792/what-do-i-need-to-do-so-the-function-isspace-work-in-c