我继续收到一个关于我的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; }
该计划尚未完成,所以任何帮助都会很精彩!关于缩短或任何事情的提示都受到欢迎。