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
Where register variables are stored in c?
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
What is the ANSI C Standard?
How would you rename a function in C?
Write a program which returns the first non repetitive character in the string?
in iso what are the common technological language?
How are 16- and 32-bit numbers stored?
Why use int main instead of void main?
What is a stream in c programming?
FILE PROGRAMMING
What is the use of pragma in embedded c?
what is use of malloc and calloc?
Is fortran faster than c?
why we wont use '&' sing in aceesing the string using scanf
Write a program in c to replace any vowel in a string with z?