在#define中,标准只定义了#和##两种操作。#用来把参数转换成字符串,##则用来连接前后两个参数,把它们变成一个字符串。
1
#include <iostream>
2
#include <fstream>
3
using
namespace
std;
4
#define
D(A) T<< #A << endl;
5
inline
void
assure(std::ofstream &
in
,
const
char
* filename=
""
)
6
{
7
if
(!
in
)
8
{
9
fprintf(stderr,
"
could not open file %s \n
"
,filename);
10
exit(
1
);
11
}
12
}
13
int
main()
14
{
15
ofstream T(
"
format.out
"
);
16
assure(T);
17
D(
int
i =
47
;);
18
return
1
;
19
}
输出到文件
int i=47;

