Dullone 2020-07-10 10:45 采纳率: 0%
浏览 69

C++中,在录入数据模块录入时,编译通过但运行时有错误,怎么改正?

struct Laptop
{
char model[32];
char color[16];
int price;
};
struct Student
{
char ID[15];
char Name[20];
Laptop* computer;
};
Student data[100];
int count = 0;
int input(Student* s)
{
printf("ID:");
gets_s(s->ID);

printf("Name:");
gets_s(s->Name);

printf("Computer:");
gets_s(s->computer->model);//运行有错误
getchar();
gets_s(s->computer->color);//运行有错误
getchar();
scanf_s("%d", &s->computer->price,sizeof(s->computer->price));//运行有错误

return 0;

}

  • 写回答

1条回答 默认 最新

  • 芒种、 2020-07-10 11:24
    关注

    没有为Student里面的指针初始化

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料