Semester : S1 and S2
Subject : Computer Programming
Year : 2017
Term : DECEMBER
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:20
It compares the two strings and returns an integer value. If both the strings are same (equal) then this function would
return 0 otherwise it may return a negative or positive value based on the comparison.
If string1 > string2 OR string] is a substring of string2 then it would result in a negative value. If string! > string2
then it would return positive value.
If string1 == string2 then you would get O(zero) when you use this function for compare strings.
Example of strcmp:
#include
#include
{ char s1[20] = "BeginnersBook";
char s2[20] = "BeginnersBook.COM";
if (stremp(sl, 52) ==0)
{
printf ("string 1 and string 2 are equal");
jelse {
printf ("string 1 and 2 are different") ;
}
return 0; } Output:
string 1 and 2 are
different
5. strrev()
உ. strrev() function reverses a given string in ( language.
#include
#include
int main()
{
char name[30] = "Hello"; — printf("String
before strrev( ) : %s\n",name); printf("String
after strrev( ) : %s",strrev(name));
return 0;