STRING LIBRARY
FUNCTIONS
Overview
WHAT ARE STRINGS??
TYPES OF STRING LIBRARY FUNCTIONS.
REFRENCES.
WHAT ARE STRINGS????
Strings are actually one-dimensional array of characters
terminated by a null character '0'.
Thus a null-terminated string contains the characters
that comprise the string followed by a null.
STRING LIBRARY FUNCTIONS
Following are the functions defined in the header (string.h)file.
• strlen()
• strcmp()
• strcpy()
• strcat()
strlen()
This function returns the length of the string i.e. The
number of characters in the string excluding the
terminating null character. It accepts single argument.
For example- strlen(“suresh”) returns the value 6.
This function is used for comparison of two strings.
If the two strings match it will return the value 0,else it will
return a non-zero value.
For example- strcmp(s1,s2) returns the value-
< 0 when s1<s2
= 0 when s1=s2
> 0 when s1>s2
strcmp()
This function is used for copying one string to another string.
strcpy(str1,str2) copies str2 to str1.
Here str2 is the source string and str1 is the designation
string.
If str2=“suresh” then it copies suresh into str1.
strcpy()
This function is used for concatenation of two strings.
If first string is “king” and second string is “size” then after
using this function he first string becomes “kingsize”.
strcat()
THANK YOU FOR PAYING
ATTENTION
THANK YOU

String Library Functions

  • 1.
  • 2.
    Overview WHAT ARE STRINGS?? TYPESOF STRING LIBRARY FUNCTIONS. REFRENCES.
  • 3.
    WHAT ARE STRINGS???? Stringsare actually one-dimensional array of characters terminated by a null character '0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.
  • 4.
    STRING LIBRARY FUNCTIONS Followingare the functions defined in the header (string.h)file. • strlen() • strcmp() • strcpy() • strcat()
  • 5.
    strlen() This function returnsthe length of the string i.e. The number of characters in the string excluding the terminating null character. It accepts single argument. For example- strlen(“suresh”) returns the value 6.
  • 7.
    This function isused for comparison of two strings. If the two strings match it will return the value 0,else it will return a non-zero value. For example- strcmp(s1,s2) returns the value- < 0 when s1<s2 = 0 when s1=s2 > 0 when s1>s2 strcmp()
  • 9.
    This function isused for copying one string to another string. strcpy(str1,str2) copies str2 to str1. Here str2 is the source string and str1 is the designation string. If str2=“suresh” then it copies suresh into str1. strcpy()
  • 11.
    This function isused for concatenation of two strings. If first string is “king” and second string is “size” then after using this function he first string becomes “kingsize”. strcat()
  • 13.
    THANK YOU FORPAYING ATTENTION THANK YOU