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
Does * p ++ increment p or what it points to?
Explain what does it mean when a pointer is used in an if statement?
Explain what is wrong with this program statement? Void = 10;
Why pointers are used in c?
List the variables are used for writing doubly linked list program.
Implement bit Array in C.
What is the use of function overloading in C?
What is the heap in c?
What is getch () for?
What is c token?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
can any one tel me wt is the question pattern for NIC exam
What is difference between structure and union in c?
What is a pragma?
What is the general form of a C program?