您的位置:首页 > 其它

Cracking the Coding Interview Q1.2

2014-07-03 09:31 369 查看
Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.

void reverse(char *str) {
char * end = str;
char tmp;
if (str) {
while (*end) {
++end;
}
--end;
while (str < end) {
tmp = *str;
*str++ = *end;
*end-- = tmp;
}
}
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: