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

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
int xstrcmp(char*,char*);
void main()
{
int c;
char a1[20],a2[20];
printf("enter the two strings :");
gets(a1);
gets(a2);
c=xstrcmp(&a1[0],&a2[0]);
printf("%d",c);
getch();
}
int xstrcmp(char *a,char *a1)
{
if((*a)!=(*a1))
return((*a)-(*a1));
else if((*a)!='\0' && (*a1)!='\0')
{
(*a)++;
(*a1)++;
xstrcmp(a,a1);
}
else
return 0;
}

Is This Answer Correct ?    5 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we change the value of constant variable in c?

823


What is the use of header?

841


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1700


When should you not use a type cast?

894


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

2107


What is a volatile keyword in c?

903


What is pass by reference in c?

871


What is the difference between a string and an array?

926


How can you access memory located at a certain address?

874


what is the structure pointer?

1865


What is a dynamic array in c?

825


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

1851


What is self-referential structure in c programming?

903


In c language can we compile a program without main() function?

851


What are disadvantages of C language.

883