// isspace example // Check if character is a white-space // that is, space, tab, newline, CF/LF // source: http://www.cplusplus.com/ #include #include #include char GetUserInput(void); int main() { char c; int i=0; char str[]="Example sentence to test isspace\n"; while (str[i]) { c=str[i]; if (isspace(c)) c='\n'; putchar(c); i++; } // another part of the program removes whitespaces for input printf("You input %c\n", GetUserInput()); return EXIT_SUCCESS; } char GetUserInput(void) { printf("\nEnter p, r, s, g, h, e:"); char c; // Checks whether c is a white-space character. // including space, newline, tab while (isspace( c = getchar())) ; return c; }