Hi, I am trying to use strcpy on a member from a structure, but my program crashes when i try to run it.
Here are the structures:
Code:
typedef struct
{
char last[NAMESIZE];
char first[NAMESIZE];
}name;
typedef struct
{
int id;
name name;
float score;
}record;
typedef struct
{
record *data;
size_t nalloc;
size_t nused;
}record_list;
and here is the code which is in a function that crashes the program:
Code:
int list_insert(record_list *list, const record *rec)
{
size_t i;
list->nalloc = 0;
list->nused = 0;
strcpy(list->data[list->nused].name.first, "michael");
return 0;
}