如何打印char阵列的地址
How to print the address of char array
http://ideone.com/4p1gqr
#include <iostream>
int main(int argc, char** argv)
{
float *f = new float[10];
std::cout << f << std::endl;
std::cout << f + 3 << std::endl;
char *c = new char[10];
std::cout << c << std::endl; // no print
std::cout << c + 3 << std::endl; // no print
return 0;
}
stdout
0x2b3cbaf1bc20
0x2b3cbaf1bc2c
如何打印char数组的地址?
您需要施放到void*
以调用operator <<
的正确超载,而不是输出为C字符串
std::cout << static_cast<void*>(c) << std::endl;
std::cout << static_cast<void*>(c+3) << std::endl;
相关文章:
- Arduino(C )condenate char*阵列与float数组
- char,const char*阵列问题,用于mqtt client.publish
- 为什么Xor-ing两个“ char”阵列显示垃圾位
- 从char阵列中提取十六进制数字
- 我如何使我的循环转到char*阵列的尽头,并将每个城市都放在链接的列表中(城市被划分为白色的空间)
- CIN正在为char阵列工作,但不为int阵列工作
- 为什么在使用SizeOf进行同一char阵列时会得到各种结果
- 如何打印char阵列的地址
- 如何将char阵列的中间单词更改为向后
- 我如何格式化十六进制中“未签名char”阵列的值
- 创建char阵列时,其长度与所需的长度不同
- C 2D char阵列有时会在随机位置复制数据
- 如何创建一个构造函数,该构造函数吸收char阵列
- Char阵列中的特定索引的C 拉动签名整数
- 在C 中乘以两个char阵列
- 无效的char阵列分配
- 如何使用3D char数组调整双指针2D char阵列的大小
- 为什么这两个char阵列不相等
- 使用Strcat的2个char阵列的串联
- Qthread char阵列在两个线程之间传递后被摧毁