|
From: <com...@ya...> - 2002-11-18 19:16:12
|
i tried to write a code using linked lists to implement the multiplication and addition of twp polynomials but it seems i'm not very successfull cause my pop funcition doesn't do what it should and i don't know why i get that access violation error ..could any one help??
thanx...
/* definitions*/
typedef struct node{
int coefficient;
int exponent;
struct node *next;
}node;
typedef struct stack{
node *firstptr;
}stack;
/*and the pop function*/
node *pop(stack *s){
node *ptr=new node;
if(nptr==NULL){
cout<<"exhausted memory"<<endl;
exit(1);
}
else{
nptr->coefficient=s->firstptr->coefficient;
nptr->exponent=s->firstptr->exponent;
s->firstptr=s->firstptr->next;//that's the problematic part
}
return nptr;
}
---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site |