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.
I already did a version just like what you said for my program, as a last resort. But it's required that the user will input the whole polynomial. Right now, I'm trying to do a polynomial parser, and it doesn't work T_T