why does s2>s1 dont work and also the "equal to", it always shows "is greater than" whenever i compile it.
Code:
#include<iostream.h>
#inlcude<conio.h>
#inlcude<string.h>
#include<stdio.h>
main()
{
clrscr();
char s1[40];
char s2[40];
cout<<"Enter 1st String:";
gets(s1);
cout<<"Enter 2nd String:";
gets(s2);
strcmp(s1,s2);
if(s1>s2)
{
cout<<s1<<" is greater than "<<s2;
}
else if (s2>s1)
{
cout<<s2<<" is greater than "<<s1;
}
else
{
cout<<s1<<" is equal to "<<s2;
}
getch();
return 0;
}
Comment