i am having trouble printing data got thru dynamic mem alloc in c++... this is the code please help......please note that if i declare both power and coeff as int it seems to work fine
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
class polynomial
{
public: int power;
float coefficient;
class polynomial *nextpolynomial;
};
class polynomial *first,*next,*newnext;
void input()
{
first = (class polynomial *)malloc(sizeof(class polynomial *));
cout<<"\nEnter the coefficient";
cin>>first->coefficient;
cout<<"\nEnter the power";
cin>>first->power;
first->nextpolynomial=NULL;
}
void nextinput()
Use [ code ] [ /code ] tags. And be a bit more descriptive about the problem - what do you expect to happen, and what happens? Also, only post the relevant section of your code.
am sorry am new to this forum and to pgmming...to be honest i do not know which part of the code is in error ..thaz why i put in the whole code...i am trying to create a code for polynomial differentiation using linked lists((i have just got the input in the above code and displaying it)). The value of power prints just fine but the coefficient value is printing some junk values...please help...i have reposted the code taking out irrelevant (( i think)) code...thanks a lot for replying