永发信息网

vs2013中c语言不能从控制台输入字符串

答案:2  悬赏:80  手机版
解决时间 2021-03-02 18:53
  • 提问者网友:却不属于对方
  • 2021-03-02 12:52
#include
#include
struct Student
{
char name[10];
long id;
double math;
double english;
};

Student* creatAStudent(){
struct Student student;
//student = (student)malloc(sizeof(struct Student));
printf("请输入学生的名字\n");
scanf_s("%s", student.name);
printf("请输入学生的学号\n");
scanf_s("%d", student.id);
printf("请输入学生的数学成绩\n");
scanf_s("%d", student.math);
printf("请输入学生的英语成绩\n");
scanf_s("%d", student.english);
return &student;
}

void main(void){
struct Student *student = creatAStudent();

}

为什么程序不能正常运行?
最佳答案
  • 五星知识达人网友:西岸风
  • 2021-03-02 13:10
是可以输入的
scanf_s("%s", student.name);
写为 scanf_s("%c", &student.name);
下面的也要改 scanf_s()
全部回答
  • 1楼网友:等灯
  • 2021-03-02 14:40

就是个搜索字符串的函数嘛

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯