Im am trying to write a program that collects the information of students. I am using an array of students(structs)
typedef struct {
char name[50];
struct Course* course;
}Student;
and in my main() i did this
Student* stds = (Student*) malloc(app.std_cnt * sizeof(*stds) );
getStdData(stds);
here is the getStdData function
void getStdData(struct Student *students){
int i;
char name[50];
Student std;
printf("\n");
for(i = 0; i < app.std_cnt; i++){
printf("std [%i] name : ",i+1);
scanf("%s",&name);
strcpy(std.name,name);
students[i] = std;
}
}
when i compile i get
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
gpa.c
gpa.c(124): error C2440: '=': cannot convert from 'Student' to 'Student'
can anyone tell me what i'm doing wrong? and why is is complaning about a Student to Student conversion? are they not of the same type?