1 int main()
 2 {
 3     char *s2 = "jwdajkj";
 4     char *s1 = new char[strlen(s2)+1];
 5     
 6     char *s3 = static_cast<char*> (memcpy(s1, s2, strlen(s2) + 1));
 7     printf("%p,%p\n", s3, s1);
 8     cout << s3 << endl;
 9     cout << &s3[0] << endl;
10     cout << static_cast<void*>(s3) << endl;
11 }

需要转换为void*指针,重载的操作符<<遇到地址会自动输出字符串

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-07-10
  • 2021-05-12
  • 2021-04-29
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
相关资源
相似解决方案