迅雷笔试 字符串反转 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;
}
相关文档:
Reading and Writing Excel file with pure C api in windows system. tested on windows 2000, hope it can help you:
#ifndef _WINXLS_H_
#define _WINXLS_H_
/*============================================================================*
* Include Files
*================== ......
2009-09-13 16:42:43
今天实现堆栈结构部分的代码,并用一简单程序测试成功。
stack.h:
#ifndef _STACK_H_
#define _STACK_H_
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define STACK_INIT_SIZE 5
#define STACKINCREMENT 5
t ......
1,防止一个头文件被重复包含
#ifndef COMDEF_H
#define COMDEF_H
//头文件内容
#endif
2,重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类型字节数差异,方便移植。
typedef unsigned char boolean; /* Boolean value type. */
typedef ......