论坛: 编程破解 标题: 牛码一段 复制本贴地址    
作者: SysHu0teR [syshunter]    版主   登录
代码:

/* fun.h */

#ifndef AUTO_INCLUDE
#define AUTO_INCLUDE

#define TYPE int
#define FUNC swap_i
#include __FILE__

#define TYPE char
#define FUNC swap_c
#include __FILE__

#undef AUTO_INCLUDE
#endif

#ifdef AUTO_INCLUDE
void FUNC(TYPE *a, TYPE *b)
{
        TYPE tmp;
        tmp = *a;
        *a = *b;
        *b = tmp;
}
#undef TYPE
#undef FUNC
#endif


代码:

/* main.c */
#include "fun.h"
main()
{
int i=10,j=20;
char a='a',b='b';
swap_i(&i,&j);
swap_c(&a,&b);
printf("%d %d\n",i,j);
printf("%c %c\n",a,b);
getchar();

}


在www.google.com/codesearch搜索下#include __FILE__,用这种技巧的代码还真不少。

地主 发表时间: 07-01-26 13:52

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号