Write a program to compare two strings without using the
strcmp() function
Answer Posted / madiha
“PROGRAM THAT COPMPARE TWO STRINGS”
#include <iostream>
using namespace std;
int mycomp(char str1[],char str2[])
{
int i=0;
while(1)
{
if(str1[i]>str2[i])
return 1;
if(str1[i]<str2[i])
return -1;
else if(str1[i]=='\0'||str2[i]=='\0')
return 0;
i++;
}
}
int main()
{
cout<<mycomp("madiho","madiha");
return 0;
}
OUTPUT
1
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the -> in c?
What is c value paradox explain?
What are the standard predefined macros?
p*=(++q)++*--p when p=q=1 while(q<=6)
What is sorting in c plus plus?
What does printf does?
What is void main ()?
Is struct oop?
Why is c called c not d or e?
Explain the difference between getch() and getche() in c?
What is c preprocessor mean?
In which language linux is written?
What is a double c?
What is the difference between malloc() and calloc()?
Explain how does free() know explain how much memory to release?