strcmpの戻り値の文字列比較

strcmpの戻り値

Linuxのvimの下で;

戻り値は、前の文字列から次の文字列を引いた値です。
strcmpの戻り値の文字列比較
strcmpの戻り値の文字列比較

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

strcmpの戻り値の文字列比較
0を返すのと同じです。最初の値は2番目の値よりも大きく、1を返し、2番目の値は-1を返します。

おすすめ

転載: blog.51cto.com/14982125/2676826