reading command line or text file...expression tree (sort of)

I am trying to learn about C++, but I don't quite know how to do the following. I am currently writing a program to compute the zeros, both complex and real, for a polynomial. I am doing this on my own to learn more about C++. I already have several methods (Madsen and various other newton methods) for finding the zeros. That isn't what I need help with.

I am using the following structures:

Code:

`//define complex numbers`

typedef struct {

double r, i;

} _comp_t;

typedef _comp_t comp_t[1];

//define polynomials, MAX_DEG is defined elsewhere

typedef struct {

comp_t coef[MAX_DEG+1];

int degree;

} poly_t;

//I also have other functions for dividing, multiplying, finding the GCD, etc for the polynomials

I can create polynomials by doing the following, for example:

Code:

`poly_t f;`

f.coef[0] -> r = 1.0; f.coef[0] -> i = 0.0;

f.coef[1] -> r = 0.0; f.coef[1] -> i = 0.0;

f.coef[2] -> r = 1.0; f.coef[1] -> i = 0.0;

to create the polynomial x^2 + 1. However, modifying the source code each time I want to test a new polynomial is cumbersome and very time consuming. So, I wrote a program to take a polynomial off of the command prompt. For example, I could enter:

>(1)x^2 + (-3)x + (7-2i);

The only way I could get the coefficients is to wrap them in parantheses. I am also allowing for complex coefficients. And, I'm assuming that all the polynomials are written in the variable 'x'.

I would like a way to enter a polynomial from the command prompt (or text file) without having to use parentheses around the coefficients. (Since this is for me, I can assume that 'x' is the only variable.) Maybe something like:

>4*x^3 - 4*x + 4;

would be fine.

I thought about using an expression tree, but I don't have much experience with them. I can program algorithms no problem, but I have very little experience with iostreams and user interfaces. Most of the information I've found on expression trees are about evaluating the expressions. But, in this case I don't really want to evaluate the expression; I just need the coefficients and the degree of each term.

Any help would be greatly appreciated. Or, even if someone could point me in the right direction, that would be great too. If I could just get a general idea on how to proceed, that would benefit me greatly, too.

Cheers.