您的位置:首页 > 其它

VS2005编译器自定义宏__FILE__,__LINE__,__TIME__

2016-06-26 11:45 274 查看
#include "stdio.h"
#include "string.h"
#include "windows.h"

void Test(void)
{
char *cp_str = NULL;
cp_str = new char[100];
strcpy(cp_str,"Hello,world!");
printf(cp_str);

return;
}

void main()
{
Test();
int a[3] = {1,2,3};
int *p, *q;
p=a;
q=&a[2];
int b = a[q-a];
printf("\na[q-a] = %d\n",b);

printf("当前文件名:%s\n",__FILE__);//输出当前程序文件名

printf("当前行号:%ld\n",__LINE__);//输出源文件的当前行号

//printf("当前日期:%d%d%d\n",__DATE__ );//

//printf("当前编译编译的是C++还是C程序:%s\n",__STDC__ );

#ifdef __cplusplus
printf("当前编译的是C++程序\n");

#else
printf("当前编译的是C程序");

#endif

printf("当前时间%s\n",__TIME__ );

system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  编译器