I am writing a small database. The structure includes the student's last name and 3 grades. All this needs to be pushed into a simply-connected linear list and work with it further. When I want to create any element of the list, the compiler outputs: "The expression must be valid for changing the left-hand value". What is the problem? Code:
struct students { char surname[20]; int marks[3]; } onestudent; struct studentlist { students a; studentlist *next; }; void main() { setlocale(LC_ALL, "Russian"); studentlist *u = NULL; //указатель на начало списка u = new studentlist; u->a.surname = scanf("%s", onestudent.surname); for (int i = 0; i < 3; i++) { u->a.marks = scanf("%d", onestudent.marks[i]); } //... }
newin C! - PinkTuxvoid * new(size_t size) { return malloc(size); }void * new(size_t size) { return malloc(size); }... - PinkTuxscanf("%s", onestudent.surname).onestudent.surname- it’s not at all clear what is. Should bescanf("%s", &(u->a.surname))- andy.37