由于sql语句错误而无法上传图片

问题描述 投票:0回答:1
char john[] = "John Doe";

    //std::cout << std::hex;
    for(int i=0; john[i]; i++) {
        std::cout << (int*)&john[i] << "---" << john[i] << std::endl;
    }

    std::cout << "-------------------------------------------------" << std::endl;

    std::cout << std::hex;
    for(int i=0; john[i]; i++) {
        std::cout << &john[i] << "---" << john[i] << std::endl;
    }

有人可以解释这个代码,这个顶层叫什么名字?

我希望第二个循环显示每个索引的内存地址

而且我想并返回地址位置,但是为什么这段代码返回值?

c++ memory-address
1个回答
0
投票

用作字符串的字符数组为NUL终止

在C ++中;ostream具有operator <<的重载,以打印出完整的NUL终止的字符串。

© www.soinside.com 2019 - 2024. All rights reserved.