Adding to what Rick York said in comments, also make a separate function for each basic polynomial operation you want to support. One really useful one would be a
find_exponent(struct node *poly, int exponent, bool insert)
function that would search the (poly) linked list for a term with the given (exponent) and return a pointer to it if found. If there is no term, either insert a new term (with a zero coefficient) if the (insert) argument is true and return that pointer, or return NULL if (insert) is false. Another is a function
remove_term(struct node *poly, struct node *term)
that would unlink a given term from a polynomial and free it. Given those, you could then write a simple monomial add function with something like:
struct node *add_monomial(struct node *poly, int exponent, float coeff)
{
struct node *term = find_exponent(poly, exponent, 1);
term->coeff += coeff;
if (term->coeff == 0.0) remove_term(poly, term);
return poly;
}
The idea here is to build a "toolbox" of basic functions you can use to get higher-level things done. Each function should do something useful, but be small enough that you can write and test it fairly quickly. You've already done just that with
del_list()
. These little utility functions make the "business" part of your code easier to write and easier to read.
Also, don't try to write them all at once. Write each one and test it separately, if you can. The first one I'd write is
print_poly(struct node *poly)
, tested with a couple of "hand-constructed" linked lists, and then start coding and testing the individual pieces needed to create a polynomial from console input. Once you can read and write, then start working on arithmetic.