The return value of strcmp
Under vim under linux;
The return value is the value of the preceding string minus the following string;
Under vs2019:
#include<iostream>
using namespace std;
int main()
{
char ch[] = "asdasd";
char ch2[] = "asdasd";
char ch3[]= "asdas2";
char ch4[] = "asdasd123";
int num = strcmp(ch, ch2);
int num2 = strcmp(ch, ch3);
int num3= strcmp(ch, ch4);
cout << num << endl;
cout << num2 << endl;
cout << num3 << endl;
}
Equal to return 0; the first one is greater than the second one returns 1, and the second one returns -1;