我从网上获得了一个源代码,但有一行对我来说很模糊.我有一个功能:
double dict(const char *str1, const char *str2) {
Run Code Online (Sandbox Code Playgroud)
并且此函数中的一行为:
if (strlen(str1) != 0 && strlen(str2) != 0)
while (prefix_length < 3 && equal(*str1++, *str2++)) prefix_length++;
Run Code Online (Sandbox Code Playgroud)
运算符++在*str1 ++和*str2 ++中做了什么?
它递增指针(不是指向的东西).
(*str)++; /* Increment the character pointed at by str */
*str++; /* Increment the pointer in str */
*(str++); /* Increment the pointer in str - the same, but verbose */
Run Code Online (Sandbox Code Playgroud)
是两个非常不同的东西,虽然它们都返回++增量发生前指向的字符.