返回指针与返回值的区别

int getValue()
{
  int c = 100;
  return c;
}

int *getPointer()
{
  int c = 100;
  int *p = &c;
  return p;
}

void main()
{
  int m = 0;
  int *p = Null;
  m = getValue;
  p = getPointer();
  printf("%d %d",m,*p);
}

你可能感兴趣的:(Cpp)