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
Describe the order of precedence with regards to operators in C.
What does calloc stand for?
Write a program to print numbers from 1 to 100 without using loop in c?
Why isnt there a numbered, multi-level break statement to break out
Which is best linux os?
How will you find a duplicate number in a array without negating the nos ?
What does p mean in physics?
Explain what are its uses in c programming?
How can I sort a linked list?
What is the advantage of c?
What is storage class?
What is the difference between mpi and openmp?
Explain the meaning of keyword 'extern' in a function declaration.
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What are the standard predefined macros?