That should be:
Code:
array = malloc(var * sizeof *array);
Or to simply fix the code above:
Code:
array = malloc(sizeof(int) * var);
When sizeof is applied to a type, the type has to be in parentheses. They aren't needed when sizeof is applied to an expression.
To the OP: If you use malloc() like this, you should call free() with array when you're done with it:
Code:
int *array = malloc(sizeof *array * 5), i;
if(array == NULL) { /* Do something, memory couldn't be allocated. */ }
for(i = 0; i < 5; i++) array[i] = i;
free(array);