gpt4 book ai didi

c++ - 如何在 C++ 中打印变量名?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:10:05 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Programmatic way to get variable name in C?

在发帖之前我已经查看了一些博客。我尝试了以下代码片段...

int a=21;

int main()
{
cout<<#a<<a<<endl;
return 0;
}

我在 ubuntu 10.04 上使用 g++ 编译器。我收到以下错误:

sample.cpp:17: error: stray ‘#’ in program. 

请建议我如何打印变量名称。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com