题目:输入一个字符串,将它逆向输出。
分析:本题考查C语言的指针。
代码如下:
int GetLength(const char* _in)
{
int _length = 0;
while (*_in++ != '/0')
{
_length++;
}
return _length;
}
char* StringReverse(const char* _source, char* _dest)
{
int strLength = GetLength(_source);
for (_dest += strLength, *(_dest + 1) = 0; strLength > 0; strLength--, _dest--)
{
*_dest = *_source++;
}
return _dest + 1;
}