跳轉到內容

C++ 程式設計/程式碼/標準 C 庫/函式/strncmp

來自華夏公益教科書,開放的書籍,用於開放的世界
語法
#include <cstring>
int strncmp( const char *str1, const char *str2, size_t count );

strncmp() 函式比較 str1str2 的最多 count 個字元。返回值如下

返回值 解釋
小於 0 str1 小於 str2
等於 0 str1 等於 str2
大於 0 str1 大於 str2

如果兩個字串中的字元少於 count 個,則比較將在遇到第一個空終止符後停止。

相關主題
strchr - strcmp - strcpy - strlen - strncat - strncpy
華夏公益教科書