用C++实现void reverse(char* str)函数,即反转一个null结尾的字符串.
void reverse(char* str) { char *end = str, *begin=str; char temp; while(*end!='\0') { end++; } end--; while(begin<=end) { temp = *end; *end-- = *begin; *begin++ = temp; } }
void reverse(char* str) { char *end = str, *begin=str; char temp; while(*end!='\0') { end++; } end--; while(begin<=end) { temp = *end; *end-- = *begin; *begin++ = temp; } }