1

Code:

#include <iostream>

int main(int argc, char const *argv[])
{
  char* ptr = nullptr;
  int a = 10;
  int* tmp = &a;
  ptr = (char*)&a;
  std::cout<<&a<<std::endl;
  std::cout<<tmp<<std::endl;
  std::cout<<ptr<<std::endl;
  return 0;
}

Output:

0x7ffee733535c
0x7ffee733535c



I just want to figure out the background reason. Plz do me a favor.

Edee
  • 1,746
  • 2
  • 6
  • 14

0 Answers0