迅雷笔试 字符串反转 C库函数 strrev
char* my_strrev( char* string )
{
char *left, *right, ch;
left = right = string;
while( *right++ != '\0');
right -= 2;
while( left<right )
{
ch = *left;
*left = *right;
*right = ch;
++left; --right;
}
return string;
}
// 测试代码
int _tmain( int argc, TCHAR* argv[] )
{
char szBuf[10] = {0};
strcpy_s( szBuf, "hello" );
printf( "%s", my_strrev(szBuf) );
system( "pause" );
return 0;
}
相关文档:
打印自己的一段漂亮C程序
#include <stdio.h>
int main()
{
char *p ="#include <stdio.h>%c int main(){char *p=%c%s%c; printf(p, 10, 34, p, 34);}";
printf(p, 10, 34, p, 34);
} ......
1.介绍一下STL,详细说明STL如何实现vector.
Answer:
STL (标准模版库,Standard Template Library.它由容器算法迭代器组成。
STL有以下的一些优点:可以方便容易地实现搜索数据或对数据排序等一系列的算法;调试程序时更加安全 和方便;即使是人们用STL在 ......
In C programming language, the observer design pattern is implemented with function pointer (aka callback function). But in Qt library, it introduces signal and slot. How to link a callback function from the C callback function to the C++ siganl and slot is a problem I encounter. Call back function ......
C中的CONST
C中CONST的使用:
const是一个C语言的关键字,它限定一个变量不允许被改变。使用const在一定程度上可以提高程序的安全性和可靠性,另外,在观看别人代码的时候,清晰理解const所起的作用,对理解对方的程序也有一些帮助。
虽然这听起来很简单,但实际上,const的使用也是c语言中一个比较微妙的地 ......