II-178 Programming Concepts
else
{
strcat(str1,str2);
printf("
Final string is :-%s",str1);
x=strlen(str1);
printf("
Length of the final string:- %d" ,x);
}
getche();
}
OUTPUT:
Source String:-C is
Destination String:-easy language
Final string is :-C is easy language
Length of the final string:- 16
Use of memcmp() function
20. Find length of strings with memcmp() function
#include <string.h>
#include <conio.h>
void main()
{
char text[30]="LATUR",text1[20]="UDGIR",chp;
clrscr();
printf("
First text is:-%s",text);
printf("
Second text is :-%s",text1);
chp=memcmp(text,text1,5);
if (chp!=0)
printf("
Text length of first string is same as of
second");
else
printf("
Text length of the strings are not same ");
getche();
}
OUTPUT:
First text is:-LATUR
Second text is:-UDGIR
Text length of first string is same as of second
M08_ITL-ESL4791_02_SE_C08.indd 178 12/22/2012 5:03:31 PM