运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
转到 Spaces
#include <iostream> #include <cstring> using namespace std; int main() { char myStr1[] = "ABCD"; char myStr2[] = "ABCE"; int cmp = memcmp(myStr1, myStr2, 4); 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; }
ABCE 大于 ABCD