#include <stdio.h>
#include <ctype.h>
int main() {
char c = ' ';
if (isspace(c)) {
printf("The character is a whitespace character.\n");
} else {
printf("The character is not a whitespace character.\n");
}
return 0;
}
In this example, the isspace() function is used to check whether the variable c
contains a whitespace character (in this case, a space). If c is a whitespace
character, the program prints the message "The character is a whitespace character."
Otherwise, it prints the message "The character is not a whitespace character."
#include <stdio.h>
int main() {
char c = ' ';
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v') {
printf("The character is a whitespace character.\n");
} else {
printf("The character is not a whitespace character.\n");
}
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main() {
char c = '.';
if (ispunct(c)) {
printf("The character is a punctuation character.\n");
} else {
printf("The character is not a punctuation character.\n");
}
return 0;
}
In this example, the ispunct() function is used to check whether the variable c
contains a punctuation character (in this case, a period). If c is a punctuation
character, the program prints the message "The character is a punctuation character.
" Otherwise, it prints the message "The character is not a punctuation character."
#include <stdio.h>
int main() {
char c = '.';
if (c == '.' || c == ',' || c == ';' || c == '?' || c == '!' || c == ':' || c == '-') {
printf("The character is a punctuation character.\n");
} else {
printf("The character is not a punctuation character.\n");
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: