'char'变量的地址? [英] Address of 'char' variable ?
问题描述
我知道看到不同变量的地址有不同的数据类型,但我在练习中看到没有显示char类型变量的地址
告诉我为什么编译器没有显示地址变量的字符类型,如其他int,float等
我尝试过:
i知道这个方法来查看任何类型变量的地址
char a;
cout<< & a<< endl;
如果你知道任何其他方法然后告诉我
谢谢
i know to see the address of different variables having different datatypes but i see during my practice that address of char type of variable is not shown
tell me why the compiler did not show the address for character type of variable like the others int ,float etc
What I have tried:
i know this method to see the address of any type of variable
char a;
cout<< &a <<endl;
if u know any other method then tell me
Thanks
推荐答案
cout << reinterpret_cast<void *>(&a) << endl;
(<<
运算符重载 char *
参数假设它正在处理 C
-like string)
(the <<
operator overload for char *
argument assumes it is dealing with a C
-like string)
你可以通过掌握一本关于C或C ++的好书或找到在线教程,了解所有这些基本问题的答案。
You could learn the answer to all these basic questions by getting hold of a good book on C or C++, or finding an online tutorial.
这篇关于'char'变量的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!