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

Answer Posted / mallesh

#include<stdio.h>
#include<conio.h>
int xstrcmp(char*,char*);
void main()
{
int c;
char a1[20],a2[20];
printf("Enter the two string's :\n");
gets(a1);
gets(a2);
c=xstrcmp(&a1[0],&a2[0]);
printf("%d",c);
getch();
}
int xstrcmp(char *a,char *a1)
{

while((*a)==(*a1))
{
if((*a=='\0')||(*a1=='\0'))
break;
++(a);
++(a1);
}
return((*a)-(*a1));
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which programming language is best for getting job 2020?

608


Write a program to find factorial of a number using recursive function.

647


What is I ++ in c programming?

629


What is a lvalue

665


Differentiate between Macro and ordinary definition.

732






What is difference between scanf and gets?

615


Write a program to check palindrome number in c programming?

601


Explain how can a program be made to print the name of a source file where an error occurs?

692


What does calloc stand for?

652


All technical questions

1512


Can we increase size of array in c?

543


What is 02d in c?

638


What is the right way to use errno?

622


What is the difference between functions abs() and fabs()?

651


Can the “if” function be used in comparing strings?

598