【发布时间】:2021-10-06 13:51:55
【问题描述】:
#include<stdio.h>
#include<stdlib.h>
struct student {
char name[30];
};
typedef struct student sv;
int main() {
int i;
sv basedata[50] ;
int totalstudent;
do
{
printf("How many people are there: ");
scanf_s("%i", &totalstudent);
} while (totalstudent<0);
fflush(stdin);
for ( i = 0; i < totalstudent; i++)
{
printf("Person %i name: ", i + 1);
gets(basedata[i].name);
}
}
输出:
有多少人:1
第 1 个人姓名:
D:\hello\chuong7\x64\Debug\chuong6.exe(进程 26572)以代码 0 退出。
按任意键关闭此窗口。 .
为什么我在运行我的程序时不能输入第 1 个人的名字,我的程序传递到结束并且我不能得到(basedata[i].name)。对不起,我只是学英语 picture here
【问题讨论】:
-
stackoverflow.com/questions/35178520/… 解释了代码中的大部分问题。
-
现在真正的问题是您使用的是什么学习资源,因为它似乎已经过时了。
标签: c