Concetti Chiave
- The program reads a single character input from the keyboard using getchar().
- It utilizes various character handling functions from the ctype.h library to evaluate the character.
- The program prints the result of each function, showing whether the character meets specific criteria such as being a digit or a letter.
- Functions like tolower() and toupper() are used to convert the character to lower or upper case, respectively.
- The output includes checks for control characters, punctuation, and whether the character is printable or has graphical representation.
/* * Scrivete un programma che prenda in input dalla tastiera un carattere * e lo controlli con ognuna delle funzioni della libreria per la gestione * dei caratteri. * Il programma dovrà visualizzare il valore restituito da ogni funzione. * */ #include #include int main(void) { char c; /* preleva il carattere dall'input */ c = getchar(); /* stampa il valore restituito da ogni funzione in ctype.h passando come argomento c */ printf("isdigit('%c'): %d
", c, isdigit(c)); printf("isalpha('%c'): %d
", c, isalpha(c)); printf("isalnum('%c'): %d
", c, isalnum(c)); printf("isxdigit('%c'): %d
", c, isxdigit(c)); printf("islower('%c'): %d
", c, islower(c)); printf("isupper('%c'): %d
", c, isupper(c)); printf("tolower('%c'): '%c'
", c, tolower(c)); printf("toupper('%c'): '%c'
", c, toupper(c)); printf("isspace('%c'): %d
", c, isspace(c)); printf("iscntrl('%c'): %d
", c, iscntrl(c)); printf("ispunct('%c'): %d
", c, ispunct(c)); printf("isprint('%c'): %d
", c, isprint(c)); printf("isgraph('%c'): %d
", c, isgraph(c)); return 0; }