我在现场发现这部法典,似乎提交人已经走过了很长的路,我很不时理解实际的雕刻,以及相反的情况:
void strrev2(char *str)
{
if( str == NULL )
return;
char *end_ptr = &str[strlen(str) - 1];
char temp;
while( end_ptr > str )
{
temp = *str;
*str++ = *end_ptr;
*end_ptr-- = temp;
}
}
让我说一下,你把“测试”改为“试验”。
第一胎:
*end_ptr = g ;
temp = t
*str = g // is it first assigned and then incremented to point to the next location?
*end_ptr = t // is it first assigned and then decremented to point to the previous location?
第二次发生的情况如何? 我花了不起时间,因为我认为,在这个方面:
char *end_ptr = &str[strlen(str) - 1];
<代码>end_ptr将只包含一封信的地址,因此*end_ptr
work?
Anyway, if someone can explain this to me in some graphical way.. Thanks.