Hi I'm having difficulties trying to malloc a struct this is what it looks like and how I'm approaching the problem.
Thats a very basic example of my code. I get an error that ->fname must point to class/struct/union/generic type.
I'm assuming that I am not mallocing the struct properly and thats is why im getting this erro. If anyone could help me with this, I would greatly appreciate it.
Code:
struct Records { char * fname; char * lname; }; Records** g_Recs; //Array of pointers void fakefunc() { g_Recs = (struct StudentRecords **) malloc (sizeof(struct StudentRecord*)); g_Recs = (struct Records *) malloc (sizeof(struct StudentRecord)); g_Recs->fname= (char *) malloc(strlen(buffer)); }
I'm assuming that I am not mallocing the struct properly and thats is why im getting this erro. If anyone could help me with this, I would greatly appreciate it.
Comment