#include<stdio.h>
#include<string.h>
int main()
{
char str[20]={"helloz"},str1[20]={"helloa"},str2[10]={0};
int ch,i,j,k,flag,r;
printf("1.Strcpy()\n2.Strcmp()\n3.Strcat()\nEnter The Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
for(i=0;str1[i]!='\0';i++)
str[i]=str1[i];
str[i]='\0';
puts(str);
break;
case 2:
if(strlen(str)!=strlen(str1))
puts("Strings Are Not Equal\n");
else
{
for(i=0;str[i]!='\0';i++)
{
if(str[i]==str1[i])
{
flag=1;
r=str[i]-str1[i];
}
else
{
r=str[i]-str1[i];
flag=0;
}
}
if(flag==1)
printf("Strings Are Equal\n%d\n",r);
else
printf("Strings Are Not Equal\n%d\n",r);
}
break;
case 3:
for(i=0;str[i]!='\0';i++) ;
for(j=0;str1[j];j++)
str[i+j]=str1[j];
str[i+j]='\0';
puts(str);
break;
}
}
No comments:
Post a Comment