#define PI 3.141592654
#define xstr(s) str(s)
#define str(s) #s
int main()
{
string str1 = xstr(PI);
const char* str2 = xstr(PI);
cout << str1 << endl;
cout << str2 << endl;
}
以字符串形式打印宏值
最新推荐文章于 2024-04-22 09:19:12 发布
#define PI 3.141592654
#define xstr(s) str(s)
#define str(s) #s
int main()
{
string str1 = xstr(PI);
const char* str2 = xstr(PI);
cout << str1 << endl;
cout << str2 << endl;
}