Write a program to compare two strings without using the
strcmp() function

Answer Posted / bhagwati lal paliwal(b.l.paliw

ALL PERSON ARE STUPIDS THEY DONT KNOW HERE WAT THE FUNCTION
STRCMP DO IT COMPARE BOTH STRING AND RETURN AN INTEGER
VALUE BUT ALL STUPID ARE COMPARING THE LENGTH OF STRING NOT
CHARACTER
Now the right answer by me follow me............
and tell me if this code work properly on
bl_paliwal77@yahoo.com

#include<stdio.h>
#include<string.h>
int cmpstr(char s1[10], char s2[10]);

int main() {
char arr1[10] = "Nodalo";
char arr2[10] = "nodalo";
printf(" %d", cmpstr(arr1, arr2));

return 0;
}


int cmpstr(char s1[10], char s2[10])
{

int i = strlen(s1);
int k = strlen(s2);
int bigger;

if (i < k) {
bigger = k;
}
else if (i > k) {
bigger = i;
}
else {
bigger = i;
}


for (i = 0; i < bigger; i++) {
if (s1[i] == s2[i])
{
//do nothing if value of both string are equal
}
else {
return (s1[i] - s2[i]);
}
}
return (0);
}

Is This Answer Correct ?    9 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is void main ()?

613


What does %2f mean in c?

676


Explain the process of converting a Tree into a Binary Tree.

2107


How do I create a directory? How do I remove a directory (and its contents)?

608


When should you not use a type cast?

661






How main function is called in c?

631


Why array is used in c?

553


List the variables are used for writing doubly linked list program.

1625


How to Throw some light on the splay trees?

621


differentiate built-in functions and user – defined functions.

628


What are the types of bitwise operator?

665


What is the process to create increment and decrement stamen in c?

588


Why is c not oop?

539


What is int main () in c?

627


What are static variables in c?

629