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
Can we change the value of constant variable in c?
What is the use of header?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
When should you not use a type cast?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
What is a volatile keyword in c?
What is pass by reference in c?
What is the difference between a string and an array?
How can you access memory located at a certain address?
what is the structure pointer?
What is a dynamic array in c?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What is self-referential structure in c programming?
In c language can we compile a program without main() function?
What are disadvantages of C language.