<ctype.h>
中。int isspace(int c);
#include <stdio.h> #include <ctype.h> int main() { char str[] = "Hello\tWorld\n! "; for(int i = 0; str[i] != '\0'; i++) { if(isspace(str[i])) { printf("Character at index %d is a whitespace character.\n", i); } else { printf("Character at index %d is NOT a whitespace character.\n", i); } } return 0; }输出结果为:
Character at index 0 is NOT a whitespace character.
Character at index 1 is NOT a whitespace character.
Character at index 2 is NOT a whitespace character.
Character at index 3 is NOT a whitespace character.
Character at index 4 is NOT a whitespace character.
Character at index 5 is a whitespace character.
Character at index 6 is NOT a whitespace character.
Character at index 7 is NOT a whitespace character.
Character at index 8 is NOT a whitespace character.
Character at index 9 is NOT a whitespace character.
Character at index 10 is NOT a whitespace character.
Character at index 11 is a whitespace character.
Character at index 12 is NOT a whitespace character.
Character at index 13 is a whitespace character.
本文链接:http://task.lmcjl.com/news/18209.html