回覆列表
  • 1 # 我是阿嘛

    linux中,c語言字串比較採用strcmp()函式

    在linux命令列下,man strcmp,可以看到函式說明:

    $ man strcmp

    ...

    NAME

    strcmp, strncmp - compare two strings

    SYNOPSIS

    #include

    int strcmp(const char *s1, const char *s2);

    DESCRIPTION

    The strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.

    strcmp函式比較兩個字串s1和s2. 函式返回小於0,等於0,或大於0的整數,分別對應s1

    比如 s1 = "good" s2="...this is good", 從s2取後四位進行兩個字串比較,程式碼如下:

    #include

  • 中秋節和大豐收的關聯?
  • 早期肝硬化大三陽轉小二陽好嗎?