Class assignment to write malloc in C