Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,879 questions

51,805 answers

573 users

How to use all <ctype.h> functions for classifying and converting characters in C

1 Answer

0 votes
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    int ch = 'Z';
    
    // Checks if ch is alphabetic (A-Z, a-z)
    printf("isalpha(ch) = %d\n", isalpha(ch));
    
    // Checks if ch  is alphanumeric (A-Z, a-z, 0-9)
    printf("isalnum(ch) = %d\n", isalnum(ch));

    // Checks if ch is a digit (0-9)
    printf("isdigit(ch) = %d\n", isdigit(ch));
    
    // Checks if ch is a lower-case letter (a-z)
    printf("islower(ch) = %d\n", islower(ch));
    
    // Checks if ch is a upper-case letter (A-Z)
    printf("isupper(ch) = %d\n", isupper(ch));
    
    // Checks if ch is a white-space character
    printf("isspace(ch) = %d\n", isspace(ch));
    
    // Checks is ch is a control character (0x00-0x1F, 0x7F)
    printf("iscntrl(ch) = %d\n", iscntrl(ch));
    
    // Checks if c is any printable character including space
    printf("isprint(ch) = %d\n", isprint(ch));
    
    // Checks if c is a punctuation character
    printf("ispunct(ch) = %d\n", ispunct(ch));
    
    // Checks if ch is printing character except space
    printf("isgraph(ch) = %d\n", isgraph(ch));

    // Checks if ch is a blank character (space or tab)
    printf("isblank(ch) = %d\n", isblank(ch));
    
    // Checks if ch is a hexadecimal digit (A-F, a-f, 0-9)
    printf("isxdigit(ch) = %d\n", isxdigit(ch));
    
    
    printf("tolower(ch) = %c\n", tolower(ch));
    printf("toupper(ch) = %c\n", toupper(ch));
    
       
    return 0;
}

   
/*
run:
 
isalpha(ch) = 1
isalnum(ch) = 1
isdigit(ch) = 0
islower(ch) = 0
isupper(ch) = 1
isspace(ch) = 0
iscntrl(ch) = 0
isprint(ch) = 1
ispunct(ch) = 0
isgraph(ch) = 1
isblank(ch) = 0
isxdigit(ch) = 0
tolower(ch) = z
toupper(ch) = Z

*/

 



answered Aug 29, 2017 by avibootz

Related questions

1 answer 148 views
1 answer 127 views
127 views asked May 7, 2021 by avibootz
2 answers 174 views
174 views asked Feb 15, 2021 by avibootz
...