String Handling Function


There are lots of string handling functions available in string.h header file. Here are some of the important string manipulation functions.

     
Function Purpose
strlen()

strlen() function is used to find length of string. length of string means number of characters in the string. 
strlen() function accept a string as an argument and returns an integer number which indicates length of string.
Syntax
length = strlen (StringName);

strcpy()

strcpy() function is used to copy one string into another string.
strcpy() function accepts two string (source and destination) as an argument and copy source string into destination string. It does not return any value.
Syntax:
 strcpy(DestinationString, SourceString);
 

strcat()

strcat() function is used to append (join) one string at the end of another string.
strcat function accepts two strings (string1 and string2) as an argument and append string2 at the end of string1 and result is stored in string1. It does not return any value.
Syntax:
strcat (String1, String2);

strcmp()

strcmp() funcion is used to compare one string with another string.
strcmp() function accepts two strings (string1 and string2) as an argument and returns one of the following three integer values:
0 if both string are equal.
>0 if string1 is greater then string2.
<0 if string1 is less then string2.
Syntax:
answer = strcmp (String1, String2)   

strrev()

strrev() function is used to reverse given string.
strrev() function accepts a string as an ergument and reverse the string.
Syntax:
strrev (String);

strstr()

strstr() function is used to search one string into another string.
strstr() function accepts two strings (OriginalString and SearchString) as an argument. It returns NULL if search string is not found in Original String.
Syntax:
strstr (OriginalString, SearchString);


Download Projects


Download Programs