Just so you can see that it really is correct code:
Code:
#include <stdio.h>
#include <stdlib.h>
struct event
{
int year;
int month;
int date;
int start_time;
int finish_time;
char event_description[50];
} *entry = NULL;
int num_entries = 0;
void add_new_entry(void)
{
struct event *tmp;
tmp = realloc(entry, sizeof(struct event) * (num_entries + 1));
if(tmp == NULL)
{
// Memory allocation error, take whatever actions are necessary
exit(1);
}
entry = tmp;
num_entries++;
}
int main(void)
{
int i;
for(i = 0;i < 5;++i)
add_new_entry();
return 0;
}
Code:
itsme@dreams:~/C$ gcc -Wall entry.c -o entry
itsme@dreams:~/C$
Not even a warning...