我在为我的 C 类编写程序时继续收到错误消息。我目前是一名学生,所以任何帮助都会很有用。我正在处理的当前程序要求我们输出成绩报告,但我在输入信息时收到错误消息。当我被提示输入信息时,我不断收到此错误:http: //i.imgur.com/YuiNI88.png ? 1 [1] 我不确定如何修复它。有人告诉我这与内存存储有关。我试过谷歌搜索,但没有得到任何帮助。这是我的代码:
include <stdio.h>
include <stdlib.h>
int main (void) { char Name[40]; char cid1[6]="", cid2[6]="", cid3[6]="", cid4[6]="",
cid5[6]="", cid6[6]="";
char Description1[21]="", Description2[21]="", Description3[21]="",Description4[21]="", Description5[21]="", Description6[21]="";
int hrs1 = 0, hrs2=0, hrs3=0, hrs4=0, hrs5=0, hrs6=0, GPA=0, TotalHrs=0, TotalPoints=0; char grade1[2]="",grade2[2]="",grade3[2]="",grade4[2]="",grade5[2]="",grade6[2]="";
printf("Enter Students Name ");
fgets(Name, 20, stdin);
printf("Enter Class ID ");
fgets(cid1, 6, stdin);
fflush(stdin);
printf("Enter Class Description ");
fgets(Description1, 20, stdin);
printf("Enter Class Hours ");
scanf("%d", &hrs1);
fflush(stdin);
printf("Enter Class Grade ");
scanf("%c", &grade1);
printf("Enter Second Class ID ");
fgets(cid2, 6, stdin);
fflush(stdin);
printf("Enter Class Description ");
fgets(Description2, 20, stdin);
printf("Enter Class Hours ");
scanf("%d", &hrs2);
fflush(stdin);
printf("Enter Class Grade ");
scanf("%c", &grade2);
printf("Enter Third Class ID ");
fgets(cid3, 6, stdin);
fflush(stdin);
printf("Enter Class Description ");
fgets(Description3, 20, stdin);
printf("Enter Class Hours ");
scanf("%d", &hrs3);
fflush(stdin);
printf("Enter Class Grade ");
scanf("%c", &grade3);
TotalHrs = (hrs1 + hrs2+hrs3+hrs4+hrs5+hrs6);
if (TotalHrs > 24)
printf("You're taking too many classes");
else if (TotalHrs < 1)
printf("You're not taking enough classes! Enroll in more!");
printf("%d", TotalHrs);
system("pause");
return 0; }
该程序不完整,因此任何帮助都会很棒!欢迎提供有关缩短或任何内容的提示。