#include<stdio.h>
#include<string.h>
void stringcopy(char *s1,char *s2)
{
int i,j;
j=strlen(s2);
for(i=0;i<=j;i++)
s1[i]=s2[i];
printf("string copied is %s\n",s1);
}
void stringcmp(char *s1,char *s2)
{
int i=0,j=0;
i=strlen(s1);
j=strlen(s2);
if(i==j)
{
for(i=0;i<=j;i++)
{
if(s1[i]==s2[i] );
else
{
printf("strings are not equal");
exit(0);
}
}
printf("strings are equal");
}
else
printf("strings are not equal");
}
void stringcat(char *s1,char *s2)
{
int i,j;
i=strlen(s1);
for(j=0;j<=strlen(s2);j++)
s1[i+j]=s2[j];
printf("concatinated string is:%s\n",s1);
}
void main()
{
char s1[20],s2[20];
printf("enter two strings");
scanf("%s%s",&s1,&s2);
stringcopy(s1,s2);
stringcmp(s1,s2);
stringcat(s1,s2);
}
No comments:
Post a Comment