Saturday 31 August 2013

Additional String Handling Functions | C Programming Language Material pdf



Additional String Handling Functions:

Some 'C' compilers will accept the following string handling functions which are available in header files string.h and ctype.h
Functions:
(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

 

C Programming Language Interview Questions and Answers Tutorial for beginners. Copyright 2013 All Rights Reserved