Additional String Handling Functions:
Some 'C' compilers will accept the following string handling functions which are available in header files string.h and ctype.hFunctions:
(i) strupr( ): to convert all alphabets in a string to upper case letters.
Ex:
strupr(“ delhi ”) ? “ DELHI”
(ii) strlwr( ): To convert all alphabets in a string to lower case letters.
Ex:
strlwr(“ CITY ”) ? “city”
(iii) strrev( ): To reverse a string
Ex: strrev(“ SACHIN ”) ? “NIHCAS”
(iv) strncmp( ): To compare first n characters of two strings.
Ex:
m = strncmp (“ DELHI ”, “ DIDAR ”, 2);
? m = -4
(v) strcmpi( ): To compare two strings with case in sensitive (neglecting upper
/ lower case)
Ex:
m=strcmpi(“ DELHI ”, “ delhi ”); ? m = 0.
(vi) strncat( ): To join specific number of letters to another string.
Ex:
char s1[10] = “New”;
char s2[10] = “Delhi -41”;
strncat(s1,s2,3);
? s1 will be “NewDel”.
0 comments:
Post a Comment