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

Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

943


What is an array? What the different types of arrays in c?

903


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

901


What is an arrays?

864


What is the process to generate random numbers in c programming language?

911


When a c file is executed there are many files that are automatically opened what are they files?

851


What is the difference between struct and union in C?

928


How can I recover the file name given an open stream or file descriptor?

865


What is operator promotion?

845


In c programming language, how many parameters can be passed to a function ?

902


What is structure padding and packing in c?

839


Can we use any name in place of argv and argc as command line arguments?

848


What is a null pointer in c?

879


Is array name a pointer?

843


Which are low level languages?

871