我有以下代码片段运行良好:
char* head = str;
char* tail = head;
while ( *tail ) {
++tail;
}
Run Code Online (Sandbox Code Playgroud)
我更改了while循环以简化,新代码是
char* head = str;
char* tail = head;
while ( *tail++ );
Run Code Online (Sandbox Code Playgroud)
我相信上面两个代码片段的工作方式相同.但第二个呢!在GDB中我看到,对于一个32个字符的字符串,指针尾部比头部大33,应该是31.
我真的很困惑.