I'm still generally new to C, I understand most basic concepts, and were now starting to learn much more complex tasks. Right now im stuck on a program to add polynomials, using linked lists.

My book Data Structures - An Advanced Approach Using C, is a real difficult read, and im just having problems organizing my programs files/functions. I still don't fully understand the program but im studying it, its just much easier to study when its organized correctly.

Heres my list of functions(not including list.c), any helpful advice on whether to put them all in main.c or whether or not to add another file such as poly.c would be greatly appreciated. any helpful advice regarding the program would be very nice as well.

status read_poly( polynomial *p_poly ); 
/*
*  reads standard input for coefficients and degrees and creates a   *  polynomial
*/
status write_term( term *p_term );
/*
* outputs a term of a polynomial
*/
status add_poly( polynomial *p_poly1, polynomial *p_poly2 );
/*
* Polynomial p_poly1 += p_poly2
* p_poly2 = 0
*/
status term_insert( list *p_L, int coef, int deg );
/*
* Insert a term structure in a p_L using coef and deg as the data
*/
status term_delete( list *p_L, int *p_coef, int *p_deg );
/*
* Delete a node from p_L, return the data stored in the node in
* p_coef and p_deg
*/
status traverse( list L, status (*p_func_f)() );
/*
* Call p_func_f() with the DATA field of each node in L.
* If p_func_f() ever returns ERROR, the function returns ERROR
*/
status find_key( list L, generic_ptr key, int (*p_cmp_f)(), list *p_keynode );
/*
* Find the node in L that has a data-matching key
* if the node is found, it is passed back in *p_keynode
* OK is returned.  p_cmp_f() is a cmparison function
* that returns 0 when there is a match.
*/
status destroy( list *p_L );

list list_iterator( list L, list lastreturn );
/*
* return each item of L in turn. Return NULL after last item.
* lastreturn is the value that was returned last
* If lastreturn is NULL, start at beginning of L
*/

void write_poly(polynomial poly );
/* 
* output a polynomial
*/
void destroy_poly(polynomial *p_poly );
/*
* calls the function destroy usint the c library function free
*/
void destroy( list *p_L, void ( *p_func_f)() );
/*
* Delete every node in *p_L
* if p_func_f() is nonnull, call it with the data stored in each node
*/

int cmp_degree( term *p_term1, term *p_term2 );
/*
* returns the degree of p_term1 - the degree of p_term2
*/

Well thats a pretty nice approach. Mainly you need to know one thing.Its up to the coder to use his code in the fashion he likes.If you are using these functions only in this program then let it be in main.c itself.
If you think you can use these programs in a broader sense then create a different file poly.c which you can include and continue.
The next step would be a great leap ie If you can bring your functions in the standard ASCII format so that many can use your functions then convert it as a library and header file and let your friends use it and give their feedback.

my teacher gave a big lecture on this program today in class

we gotta have list.c, list.h, main.c, polynomial.c, polynomial.h, listinterface.c and listinterface.h

This article has been dead for over six months. Start a new discussion instead.