How to print the address of char array

前端 未结 1 320
小蘑菇
小蘑菇 2021-01-21 01:39

http://ideone.com/4p1gqr

#include     

int main(int argc, char** argv)
{
  float *f = new float[10];

  std::cout << f << std::endl;         


        
1条回答
  •  隐瞒了意图╮
    2021-01-21 02:11

    You need to cast to void* to invoke correct overload of operator << instead of outputting as C strings

    std::cout << static_cast(c) << std::endl;
    std::cout << static_cast(c+3) << std::endl;
    

    0 讨论(0)
提交回复
热议问题