
Character Functions
isalpha(c) | Description: Returns true if c is alphabetic: a-z or A-Z. Ex. isalpha('A'); // Returns true isalpha(myString[0]); // Returns true because 'H' is alphabetic isalpha(myString[3]); // Returns false because '9' is not alphabetic |
isdigit(c) | Description: Returns true if c is a numeric digit: 0-9. Ex. isdigit(myString[3]); // Returns true because '9' is numeric isdigit(myString[4]); // Returns false because ! is not numeric |
isalnum(c) | Description: Returns true if c is alphabetic or a numeric digit. Thus, returns true if either isalpha or isdigit would return true. Ex. isalnum('A'); // Returns true isalnum(myString[3]); // Returns true because '9' is numeric |
isspace(c) | Description: Returns true if character c is a whitespace. Ex. isspace(myString[5]); // Returns true because that character is a space ' '. isspace(myString[0]); // Returns false because 'H' is not whitespace. |
islower(c) | Description: Returns true if character c is a lowercase letter a-z. Ex. islower(myString[0]); // Returns false because 'H' is not lowercase. islower(myString[1]); // Returns true because 'e' is lowercase. islower(myString[3]); // Returns false because '9' is not a lowercase letter. |
isupper(c) | Description: Returns true if character c is an uppercase letter A-Z. Ex. isupper(myString[0]); // Returns true because 'H' is not uppercase. isupper(myString[1]); // Returns false because 'e' is lowercase. isupper(myString[3]); // Returns false because '9' is not an uppercase letter. |
isblank(c) | Description: Returns true if character c is a blank character. Blank characters include spaces and tabs. Ex. isblank(myString[5]); // Returns true because that character is a space ' '. isblank(myString[0]); // Returns false because 'H' is not blank. |
isxdigit(c) | Description: Returns true if c is a hexadecimal digit: 0-9, a-f, A-F. Ex. isxdigit(myString[3]); // Returns true because '9' is a hexadecimal digit. isxdigit(myString[1]); // Returns true because 'e' is a hexadecimal digit. isxdigit(myString[6]); // Returns false because 'G' is not a hexadecimal digit. |
ispunct(c) | Description: Returns true if c is a punctuation character. Punctuation characters include: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ Ex. ispunct(myString[4]); // Returns true because '!' is a punctuation character. ispunct(myString[6]); // Returns false because 'G' is not a punctuation character. |
isprint(c) | Description: Returns true if c is a printable character. Printable characters include alphanumeric, punctuation, and space characters. Ex. isprint(myString[0]); // Returns true because 'H' is a alphabetic. isprint(myString[4]); // Returns true because '!' is punctuation. isprint(myString[5]); // Returns true because that character is a space ' '. isprint('\0'); // Returns false because the null character is not printable |
iscntrl(c) | Description: Returns true if c is a control character. Control characters are all characters that are not printable. Ex. iscntrl(myString[0]); // Returns false because 'H' is a not a control character iscntrl(myString[5]); // Returns false because space is a not a control character iscntrl('\0'); // Returns true because the null character a control character |
isalpha(c) | Description: 'true' if alphabetic (a-z or A-Z) Ex. isalpha('x') // true isalpha('6') // false isalpha('!') // false |
isdigit(c) | Description: 'true' if digit (0-9) Ex. isdigit('x') // false isdigit('6') // true |
isspace(c) | Description: true if whitespace Ex. isspace(' ') // true isspace('\n') // true isspace('x') // false |
toupper(c) | Description: Uppercase version Ex. toupper('a') // A toupper('A') // A toupper('3') // 3 |
tolower(c) | Description: Lowercase version Ex. tolower('A') // a tolower('a') // a tolower('3') // 3 |
char myString[30] = “Hey9! Go”;
toupper(c) | Description: If c is a lowercase alphabetic character (a-z), returns the uppercase version (A-Z). If c is not a lowercase alphabetic character, just returns c. Ex. toupper(myString[0]); // Returns 'H' (no change) toupper(myString[1]); // Returns 'E' ('e' converted to 'E') toupper(myString[3]); // Returns '9' (no change) toupper(myString[5]); // Returns ' ' (no change) |
tolower(c) | Description: If c is an uppercase alphabetic character (A-Z), returns the lowercase version (a-z). If c is not an uppercase alphabetic character, just returns c. Ex. tolower(myString[0]); // Returns 'h' ('H' converted to 'h') tolower(myString[1]); // Returns 'e' (no change) tolower(myString[3]); // Returns '9' (no change) tolower(myString[5]); // Returns ' ' (no change) |