so you want to extract all the coefficients appearing in some expression/equation.
In C, I assume the following
*you already read a string called expr,
*coefficients are the usual decimal arabic digits
*those 10 digits are contiguous and in ascending ordered in your character codification (usual)
int i = 0;
int coef = 0;
/*
*condition could be replaced with i < expr.length
*in languages that support that idiom
*/
while (expr[i] != '\0') {
if ('0' <= expr[i] && expr[i] <= '9') {
coef = (10 * coef) + (expr[i] - '0');
} else {
if (coef != 0) {
/*
* print the coefficient or store it somewhere
* and prepare for another one
*/
}
coef = 0; /* clean and prepare for another coefficient */
}
i = i + 1;
}
[code]
this kind of programs are called lexers or scanners OP. This one is extremely simple, but you can read more about them online or on a programming languages/compilers/interpreters textbook