write a own function to compare two strings with out using
stringcomparition function?

Answer Posted / sasikumar

main()
{
char s1[10],s2[10];
printf("enter two strings:");
scanf("%s%s",&s1[10],&s2[10]);
compare(s1[10],s2[10]);
getch();
}
compare(char st1[10],char st2[10])
{
int l1,l2,i;
l1=strlen(st1[10]);
l2=strlen(str2[10]);

if(l1==l2)
{
for(i=0;i<l1;i++)
{
if(st1[i]==st2[i])
{
if(i==l1)
{
printf("two strings are equal");
}

}
else
goto label:
}
}
else
goto label:
label:printf("not equal");
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between %d and %i?

592


What is NULL pointer?

671


What is a rvalue?

743


Describe how arrays can be passed to a user defined function

776


How can I call a function with an argument list built up at run time?

632






What is variable in c example?

590


Is c is a high level language?

618


Explain how can I open a file so that other programs can update it at the same time?

586


Can we declare variables anywhere in c?

575


Explain what is the benefit of using #define to declare a constant?

604


What is the use of a semicolon (;) at the end of every program statement?

764


Is c# a good language?

602


What is gets() function?

667


Explain what is output redirection?

661


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

722