我不断收到此错误,不确定如何解决。我是 C 编程的新手,尝试通过书籍/互联网搜索,但找不到太多帮助。我正在尝试创建一个程序,该程序将使用循环和结构打印成绩报告
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Grades
{
char Name[20];
char Hrs;
int ID;
char ClassName[20];
char Grade;
char ClassID[6];
};
int main ()
{
struct Grades Transcript[6];
int classCnt = 0;
int vHrs=0;
char vGrade[2];
char vName[20], vCID[6], vClassName[20];
printf("Enter Students Name: ");
fgets(vName, 20, stdin);
do
{ printf("Enter Class ID; ");
fgets(vCID, 6, stdin);
strcpy_s(Transcript[classCnt].ClassID, vCID);
printf("Enter Class Name: ");
fgets(vClassName, 20, stdin);
strcpy_s(Transcript[classCnt].ClassName, vClassName);
printf("Enter Class Hours: ");
scanf("%d", &vHrs);
strcpy(Transcript[classCnt].Hrs, vHrs); //Problem occurs here
printf("Enter Class Grade: ");
scanf("%c", vGrade);
strcpy(Transcript[classCnt].Grade, vGrade); //Problem occurs here
classCnt++;
}while(classCnt<=6);
}