//指出下面程序的问题
/*typedef struct TagStu
{
  int n;
}Stu;
void test(Stu* s[])
{
  cout<<s->n<<endl;
  cout<<(++s)->narrow<<endl;
}
int main()
{
  Stu* sTmp;
  sTmp = new Stu[10];
  test(sTmp); //传递的实参为指针,而test函数形参为Stu指针类型的数组,
  delete [] sTmp;
  return 0;
}*/

//修改为
typedef struct TagStu
{
  int n;
}Stu;
void test(Stu* s,int len)
{
  cout<<s->n<<endl;
  cout<<(++s)->n<<endl;
}
int main()
{
  Stu* sTmp;
  sTmp = new Stu[10];
  test(sTmp,10);
  delete [] sTmp;
  return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2021-08-21
  • 2021-12-05
  • 2021-11-27
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案