qfedu-c-level/day6/d17.c

25 lines
500 B
C

#include <stdio.h>
#include <string.h>
int main()
{
// char stu_names[5][32] = {"zhangsan", "lisi", "wangwu", "zhaoliu", "tianqi"};
char stu_names[5][32];
int i = 0;
while (i < 5)
{
printf("请输入第 %d 个学生的名字:", i + 1);
fgets(stu_names[i], sizeof(stu_names[i]), stdin);
stu_names[i][strlen(stu_names[i]) - 1] = '\0';
i++;
}
for (int i = 0; i < 5; i++)
{
printf("%s\n", stu_names[i]);
}
return 0;
}