Character handling functions :
Function | Result | |
isalnum(int c) | True if alphabetic or a digit. Example : char c='a'; x=isalnum(c) //x=1;(true) | |
isalpha(int c) | True if alphabetic. Example : char c='a'; x=isalpha(c) //x=1;(true) | |
isdigit(int c) | True if c is a decimal digit. Example : char c='a'; x=isdigit(c) //x=0;(false) | |
isgraph(int c) | True if c is any printing character except space. Example : char c='a'; x=isgraph(c) //x=1;(true) | |
islower(int c) | True if c is any lowercase alphabetic letter. Example : char c='a'; x=islower(c) //x=1;(true) | |
isprint(int c) | True if c is printing character (including space). Example : char c='a'; x=isprint(c) //x=1;(true) | |
isspace(int c) | True if a white space character. Example : char c=';'; x=isspace(c) //x=0;(false) | |
isupper(int c) | True if an uppercase alphabetic letter. Example : char c='a'; x=isupper(c) //x=0;(false) | |
isxdigit(int c) | True if valid hexadecimal digit. Example : char c='a'; x=isxdigit(c) //x=1;(true) |
Character mapping functions :
Function | Result | |
tolower(int c) | convert uppercase letter to lowercase letter. Example : char c='A'; x=tolower(c) //x='a'; | |
toupper(int c) | convert lowercase letter to uppercase letter. Example : char c='b'; x=toupper(c) //x='B'; |
String handling functions :
A string is an array of characters.
Function | Result | |
strlen(str) | Finds the length of str. Example : char str[10]={"cdac"}; int len; len=strlen(str); //len =4; | |
strupr(str) | Convert lower string to upper string. Example : char str[10]={"cdac"}; strupr(str); //str="CDAC" | |
strlwr(str) | Convert upper string to lower string. Example : char str[10]={"COMPuter"}; strlwr(str); //str="computer" | |
strcmp(str1,str2) | compares two strings and returns -ve no. if str1 is small , +ve. if str1 is big and 0 if both string are same. Example : char str1[10]={"AAA"},str2[10]={"ZZZ"}; int diff; diff=strcmp(str1,str2)//diff=-ve | |
strcpy(str1,str2) | Copy str2 to str1(str1=str2). Example : char str1[10],str2[10]={"AAA"}; strcpy(str1,str2);//str1="AAA" | |
strcat(str1,str2) | Concatenates two strings.str1=str1+str2 and str2=str2. Example : char str1[10]={"Sita"},str2[10]={"Ram"}; strcat(str1,str2);//str1="SitaRam" and str2="Ram". | |
strrev(str) | Reverse string. Example : char str[10]={"computer"}; strrev(str);//str="retupmoc" |