统计

  • 随笔 - 50
  • 文章 - 42
  • 评论 - 147
  • 引用 - 0

留言簿(6)

随笔分类

文章分类

Link

搜索

  •  

积分与排名

  • 积分 - 160257
  • 排名 - 161

最新评论

阅读排行榜

评论排行榜

预定义符号常量

 

C++继承了ANSI C的预定义常量,预处理器在处理代码时将它们替换为确定的字面常量。这些符号不能用#define重新定义,也不能用#undef取消该宏。

__LINE__ 引用语句的代码行号
__FILE__ 引用语句所在的文件名
__DATE__ 引用语句所在源文件被编译的时期
__TIME__ 引用语句所在源文件被编译的时间

#include<iostream>
#include <fstream>
//#include "apue.h"
//#include <sys/wait.h>
//#define MAXLINE 2048 
using namespace std;

int
main (int argv, char** arg)
{
    cout<<__LINE__<<endl;
    cout<<__FILE__<<endl;
    cout<<__DATE__<<endl;
    cout<<__TIME__<<endl;
    return 0;
}

输出:

11
test.cpp
Feb 28 2009
21:12:59

posted on 2009-03-10 10:55 pear_li 阅读(961) 评论(0)  编辑 收藏 引用 所属分类: C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理