I know I sound like a broken record, but whenever you declare a structure like this:
Code:
struct test_score
{
char subject_name[MAX_STRING];
int score;
};
You create extra work for yourself because you have to use the 'struct' keyword excessively, like so:
Code:
struct test_score* temp = malloc(sizeof(struct test_score) * NUM_OF_SUBJECT);
struct test_score test[NUM_OF_SUBJECT];
---
I mean, doing it that was is the way it was done with the 1.0 C standard of years an years ago- clumsy, overly verbose.
If you tell it it is an actual 'type' of data, it's much simpler-- like this:
Code:
typedef struct
{
char subject_name[MAX_STRING];
int score;
}test_score;
See how much simpler and easier this is:
Code:
test_score* temp = malloc(sizeof(test_score) * NUM_OF_SUBJECT);
test_score test[NUM_OF_SUBJECT];