#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");
}VS2005编译器自定义宏__FILE__,__LINE__,__TIME__
最新推荐文章于 2024-09-21 16:48:10 发布
本文展示了一个简单的C++程序示例,包括字符串操作、指针使用、数组访问及编译信息输出等基本功能。通过这个例子,读者可以了解如何在C++中进行基本的编程操作,并掌握一些预处理指令的用法。

970

被折叠的 条评论
为什么被折叠?



