I need to consider the user input character is white space or not.
The program works well when I type in a blank space, * is printed out successfully.
But when I type a character that is not white space, I can't get %.
Instead the character that I entered is just printed out.
Is there a problem with my conditional operator code?
This is my code:
#include <stdio.h>
#include <ctype.h>
int main() {
char character;
printf("Press any single key\n");
character = getchar();
(isspace(character) > 0) ? printf("*") : printf("%");
return 0;
}