How to print the address of char array

前端 未结 1 321
小蘑菇
小蘑菇 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<void*>(c) << std::endl;
    std::cout << static_cast<void*>(c+3) << std::endl;
    
    0 讨论(0)
提交回复
热议问题