Hello all - I need homework help.
This part of the assignment is to create a struct, called StudentRecord, the first attribute of which needs to be size 20. My implementation of this is at (1).
After instantiating a StudentRecord named MyStudent, I'm to assign some value to it. I chose "Test Value" and my implementation is located at (2).
The problem is I continue getting this error:
error C2440: '=' : cannot convert from 'const char [20]' to 'char [20]
followed by:
There is no context in which this conversion is possible
It shows up right when I attempt to assign the char [20] a value.
#include "stdafx.h"
#include <iostream>
#include <string>
struct StudentRecord
{
char Name[20]; // (1)
int ID;
float GPA;
};
int main()
{
StudentRecord MyStudent;
MyStudent.Name = "Test Value"; // (2) (3)
MyStudent.ID = 1234;
MyStudent.GPA = 4.0;
std::cin.get();
return 0;
}
I've spent the last few days digging online for help - and have found no leads that make sense to me. I am assuming that I'm either asking the wrong questions, querying the wrong keywords, or don't fully understand the error.
Thus I ask you for help!
Please help me understand what the error message is trying to tell me.
Thank you for your time.