String comparison of the return value of strcmp

The return value of strcmp

Under vim under linux;

The return value is the value of the preceding string minus the following string;
String comparison of the return value of strcmp
String comparison of the return value of strcmp

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;
}

String comparison of the return value of strcmp
Equal to return 0; the first one is greater than the second one returns 1, and the second one returns -1;

Guess you like

Origin blog.51cto.com/14982125/2676826