The memory allocation call is correct but the assignment is wrong. By starting the line with the type
Activity*
you are telling the compiler to create a local variable with the name specified after the type. But that name is invalid because it contains unallowed characters and you probably don't want to create a local variable but assign the allocated memory to the passed structure.
If you have the address
*sys
of an existing
RoomSystem
structure:
sys->c_array = malloc(num_challenges * sizeof(Activity));
If you have a function with a
RoomSystem **sys
parameter:
Result create_system(RoomSystem **sys)
{
*sys->c_array = malloc(num_challenges * sizeof(Activity));
return (*sys->c_array == NULL) ? RESULT_NO_MEM : RESULT_OK;
}