iltwat436
BAN USER
Comments (3)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
#include<stdio.h>
int strcompare(char *s1,char *s2)
{
int j=0;
int d=0;
while(s1[j]==s2[j]&&(s1[j]!='\0'&&s2[j]!='\0'))
{
printf("%c %c\n",s1[j],s2[j]);
d=1;
j=j+1;
}
if(s1[j]!=s2[j])
{
printf("%c %c\n",s1[j],s2[j]);
d=0;
}
return d;
}
int main(int argc,char **argv)
{
int c=0;
if(argc!=3)
{
printf("Enter two strings for comaprision\n");
return;
}
printf("%s %s %s\n",argv[0],argv[1],argv[2]);
c=strcompare(argv[1],argv[2]);
if(c)
printf("The strings are equal:%d\n",c);
else
printf("The strings are not equal\n");
return 0;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
int strcmp(char *s1,char *s2)
- iltwat436 January 17, 2013{
while(*s1++==*s2++)
;
return (*s1-*s2);
On sucess return 0, else -1;
}