Checking capital and small characters

This is a discussion on Checking capital and small characters within the C Programming forums, part of the General Programming Boards category; Is there any functions to check the character (example 'A') is in caps or small? if not, what other methods ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Singapore
    Posts
    11

    Checking capital and small characters

    Is there any functions to check the character (example 'A') is in caps or small?
    if not, what other methods are there?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    There are all the is_____ functions in <ctype.h>, such as isalpha, isupper, ispunct, islower, etc. (I'll leave it to you to figure out which ones you want.)

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Code:
    if ('a' > 'b') {
            if ((ch <= 'A') && (ch >= 'Z')) return TRUE;
    } else { 
            if ((ch >= 'A') && (ch <= 'Z')) return TRUE;
    }
    
    return FALSE;
    Think that is one way (also) -- that is if I've got all the PacMans in the right direction.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Kennedy View Post
    Code:
    if ('a' > 'b') {
            if ((ch <= 'A') && (ch >= 'Z')) return TRUE;
    } else { 
            if ((ch >= 'A') && (ch <= 'Z')) return TRUE;
    }
    
    return FALSE;
    Think that is one way (also) -- that is if I've got all the PacMans in the right direction.
    Only if you're using an ASCII machine.
    Try that on a Mainframe and it won't work.
    Just use the standard C functions if you want to write portable code.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by cpjust View Post
    Only if you're using an ASCII machine.
    Try that on a Mainframe and it won't work.
    Just use the standard C functions if you want to write portable code.
    How many folks do you know that <still> use EBCDIC?

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Kennedy View Post
    How many folks do you know that <still> use EBCDIC?
    Banks, Insurance companies, Governments...
    Those were the main customers at my previous job which made software for mainframes.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How To Make Capital Letter To Small Capital Letter??
    By jason07 in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2005, 04:37 PM
  2. FAQ chr convert from small to captial (C++)
    By hlens in forum FAQ Board
    Replies: 1
    Last Post: 11-08-2001, 04:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21