Try printing the values of variables as it uses them. It's a good debugging technique. Then you can check what is displayed matches what you expect, and if not then you've found a difference between what you thought the program was doing and what it is actually doing.

Since the problem appears to be at the evaluation part, I'd suggest doing something like:
printf("Adding ( poly[w=%d]=%d *pow(x=%d,n=%d)=%d )=%d\n", w, poly[w], x, n, pow(x,n), poly[w]*pow(x,n));
Obviously %d means int, so if any of those aren't ints then you'll need to change the relevant %d's accordingly.