Working with Strings & Standard Functions 247
8.4 STRING STANDARD FUNCTIONS
Every 'C' compiler supports a large number of strings handling library functions. Table 8.3 provides
list of frequently used functions and their description.
Table 8.3 Standard C String Library Functions
Functions Description
s t r le n O
Determines length of a string.
s tr c p y () Copies a string from source to destination.
strn cp y () Copies characters of a string to another string upto the specified length.
strcnpO
Compares characters of two strings (Function descriminates between small &
capital letters.)
stricnpO
Compares two strings. (Function doesn't discriminate between small & capital
letters.
stmarpO
Compares characters of two strings upto the specified length.
stmicmpO
Compares characters of two strings upto the specified length. Ignores case.
strlwr ()
Converts uppercase characters of a string to lowercase.
struprO
Converts lowercase characters of a string to uppercase.
strdupO
Duplicates a String.
strchr () Determines first occurrence of a given character in a string.
strrchr () Determines last occurrence of a given character in a string.
strstr ()
Determines first occurrence of a given string in another string.
strcatO
Appends source string to destination string.
stmcat ()
Appends source string to destination string upto specified length.
strrevO
Reverses all characters of a string.
street () Sets all characters of string with a given argument or symbol.
stmset ()
Sets specified numbers of characters of string with a given argument or symbol.
strspnO
Finds upto what length two strings are identical.
strpbrkO
Searches the first occurrence of the character in a given string and then it displays
the string starting from that character.
We shall elaborate the above-cited functions by providing few examples of each of them. Without
using the standard functions we can also write the programs. Few such programs are briefly described.
s t r le n O fu n ction s
This function counts the number of characters in a given string. The format of function is s t r le n
(s t r i n g ) . Program in this regard is illustrated below.