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
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)
What is an array? What the different types of arrays in c?
Explain how can I open a file so that other programs can update it at the same time?
What is an arrays?
What is the process to generate random numbers in c programming language?
When a c file is executed there are many files that are automatically opened what are they files?
What is the difference between struct and union in C?
How can I recover the file name given an open stream or file descriptor?
What is operator promotion?
In c programming language, how many parameters can be passed to a function ?
What is structure padding and packing in c?
Can we use any name in place of argv and argc as command line arguments?
What is a null pointer in c?
Is array name a pointer?
Which are low level languages?