Here is the input.txt file that I have.
2 5 -2 3 1 2 4 0
1 2 1 0
These are 2 polynominals. 2x^5 - 2x^3 + x^2 + 4 and x^2 + 1 while <3,5> : 3 is the coefficient, 5 is the degree.
I just can separate 2 lines into 2 files input.txt & input1.txt and read from them.
I want to read the first line to 1 linked list and then the second line to another linked list. Can anyone help me with this?
void readfile(char *filename, List &s, Data &x)
{
FILE *pfile;
pfile=fopen(filename,"rt");
if(pfile==NULL)
{
cout<<"Error reading!\n";
exit(0);
}
while(!feof(pfile))
{
fscanf(pfile,"%d %d ",&x.coefficient,&x.degree);
insertHead(s,x);
}
fclose(pfile);
}
void main()
{
List s,s1;
init(s);
init(s1);
Data x;
readfile("input.txt",s,x);
readfile("input1.txt",s1,x);
}