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

来源:互联网 发布:淘宝代购没有中文标签 编辑:程序博客网 时间:2024/05/29 09:34
#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程序");#endifprintf("当前时间%s\n",__TIME__ ); system("pause");}

0 0
原创粉丝点击