请帮忙看段code,为什么过不了。# JobHunting - 待字闺中
c*z
1 楼
reverse a string
void reverse(char* str)
{
// check null
if ( str == NULL ) return;
char* end = str;
char temp;
while( *end != NULL )
end++;
end--;
while( str < end )
{
temp = *str;
*str = *end; // 这里每次都会垮掉
*end = temp;
str++;
end--;
}
}
void reverse(char* str)
{
// check null
if ( str == NULL ) return;
char* end = str;
char temp;
while( *end != NULL )
end++;
end--;
while( str < end )
{
temp = *str;
*str = *end; // 这里每次都会垮掉
*end = temp;
str++;
end--;
}
}