Example for string built in function :
#include < stdio.h >
#include < string.h >
main ( )
{
char s1[30], s2[30], s3[30];
printf( " Enter any two words " ) ;
scanf( "%s%s",s1, s2);
strcpy(s3,s1);
if ( strcmp(s1,s3) == 0 )
printf( " \n Both are same " ) ;
else
printf( " \n Both are not same " ) ;
strcat ( s1, s2 );
printf( " \n Length of string %d ", strlen( s1 ));
printf ( " \n s1 = %s \n s2 = %s \n s3 = %s ", s1, s2, s3 );
}
#include < stdio.h >
#include < string.h >
main ( )
{
char s1[30], s2[30], s3[30];
printf( " Enter any two words " ) ;
scanf( "%s%s",s1, s2);
strcpy(s3,s1);
if ( strcmp(s1,s3) == 0 )
printf( " \n Both are same " ) ;
else
printf( " \n Both are not same " ) ;
strcat ( s1, s2 );
printf( " \n Length of string %d ", strlen( s1 ));
printf ( " \n s1 = %s \n s2 = %s \n s3 = %s ", s1, s2, s3 );
}
Comments
Post a Comment