tabstop referred to this line:
Code:
struct integer *num = (struct integer *)malloc(sizeof(int));
As I noted, one way to get the correct size is to use the expression being declared, i.e.,
Code:
struct integer *num = malloc(sizeof(*num));
But since at this point you just want to work with a struct integer to get the rest of the code right, you might as well create it on the stack:
Code:
struct integer num;
Consequently, you would not need to free the struct integer pointer (which you failed to do anyway). You would pass the address of num to readnum().