C-style string:'abcd' 表示5个字符,包括空字符串
注意: 注意空字符
void reverse(char *str)
{
char *end=str;
char tmp;
if(str){
while(*end) ++end;
--end; //空字符串
while(str<end)
{ tmp=*str;
*str++=*end;
*end--=tmp;
}
}
}
C-style string:'abcd' 表示5个字符,包括空字符串
注意: 注意空字符
void reverse(char *str)
{
char *end=str;
char tmp;
if(str){
while(*end) ++end;
--end; //空字符串
while(str<end)
{ tmp=*str;
*str++=*end;
*end--=tmp;
}
}
}