I wonder if parsing an arbitrary function is beyond what's expected for your assignment.
Perhaps the user can input the coefficients in another way - using multiple input prompts.
For example, "Enter coefficient for C"... "X"... "X^2"... "X^3"... These would all go into a simple array. The to evaluate you simply loop through that.