[Solved] Getting error C2440


You cannot use:

strcpy(Student.StudentGPA, "2.4");
strcpy(Student.StudentCredits, "31");

since Student.StudentGPA and Student.StudentCredits are of type double.

Use:

Student.StudentGPA = 2.4;
Student.StudentCredits = 31;

BTW, the line

strcpy(Student.StudentMajor, "TECH");

will lead to undefined behavior since Student.StudentMajor doesn’t have enough space to hold those characters and a terminating null character. Make the size of Student.StudentMajor at least 5.

strcpy(Student.StudentID, "J02062414");

suffers from the same problem. Make the size of Student.StudentID at least 10.

solved Getting error C2440