Table of Contents

    Comprehensive Guide to String Functions in C

    Comprehensive Guide to String Functions in C

    The standard function library has a rich and varied set of string- and character-handling functions. The string functions operate on null-terminated arrays of characters and require the header .

    String.h header file supports all the string functions in C language. All the string functions are given below.

    String functions
    Description
    strcat ( ) Concatenates strng2 at the end of strng1
    strncat ( ) Appends a portion of string to another
    strcpy ( ) Copies strng2 into strng1
    strncpy ( ) Copies given number of characters of one string to another
    strlen ( ) Gives the length of strng1
    strcmp ( ) Returns 0 if strng1 is same as strng2. Returns <0 if strng1< strng2. Returns >0 if strng1 > strng2
    strcmpi ( ) Same as strcmp() function. But, this function negotiates case.  "A" and "a" are treated as same.
    strchr ( ) Returns pointer to first occurrence of char in strng1
    strrchr ( ) last occurrence of given character in a string is found
    strstr ( ) Returns pointer to first occurrence of strng2 in strng1
    strrstr ( ) Returns pointer to last occurrence of strng2 in strng1
    strdup ( ) Duplicates the string
    strlwr ( ) Converts string to lowercase
    strupr ( ) Converts string to uppercase
    strrev ( ) Reverses the given string
    strset ( ) Sets all character in a string to given character
    strnset ( ) It sets the portion of characters in a string to given character
    strtok ( ) Tokenizing given string using delimiter