Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; int main() { char myStr1[] = "ABCD"; char myStr2[] = "ABCE"; int cmp = strncmp(myStr1, myStr2, 3); if(cmp > 0) { cout << myStr1 << " is greater than " << myStr2 << "\n"; } else if(cmp < 0) { cout << myStr2 << " is greater than " << myStr1 << "\n"; } else { cout << myStr1 << " is equal to " << myStr2 << "\n"; } return 0; }
ABCD is equal to ABCE