int strcmp (const char *str1, const char *str2);
int strncmp (const char *str1, const char *str2, size_t num);
Compares up to num characters of the C string str1 to those of the C string str2.
This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ, until a terminating null-character is reached, or until num characters match in both strings, whichever happens first.
str1 C string to be compared.
str2 C string to be compared.
num Maximum number of characters to compare.
strcmp(string1,string2)比較兩個string,
strncmp(string1,string2,n)則只比較前n個字元
若是string1
- Jan 17 Tue 2012 15:28
strncmp strcmp
close
全站熱搜
留言列表
發表留言