-1

tempCodeRunnerFile.cpp:1:9: fatal error: iostream.h: No such file or directory #include<iostream.h> ^~~~~~~~~~~ ~ compilation terminated.

I wrote this code but I am getting the error. How can I get rid of this.

HERE IS THE PROGRAM IN C++:

#include<iostream.h>

#include<conio.h>

class poly

{

struct node

{

int coeff,deg;

node (lin;

};

node *start,*last;

int size;

public:

poly()

{

start=NULL;

}

void getpoly();

poly operator+(poly);

void display();

};

void poly::getpoly()

{

cout<<"\n\tenter the size:";

cin>>size;

for(int i=1;i<=size;i++)

{

node *temp=new node;

cout<<"\n\tenter the coeffcint:";

cin>>temp->coeff;

cout<<"\n\tenter the degree:";

cin>>temp->deg;

temp->link=NULL;

if(start==NULL)

start=temp;

else

last->link=temp;

last=temp;

}

}

poly poly::operator+(poly p)

{

{

poly temp;

int k=0;

node *i,*j;

i=start;

j=p.start;

while((i!=NULL)&&(j!=NULL))

{

node*t=new node;

t->link=NULL;

if(i->deg==j->deg)

{

k++;

t->coeff=i->coeff+j->coeff;

t->deg=i->deg;

i=j->link;

j=j->link;

}

else if(i->deg>j->deg)

{

t->coeff=i->coeff;

t->deg=i->deg;

i=i->link;

k++;

}

else

{

t->coeff=j->coeff;

t->deg=j->deg;

j=j->link;

k++;

}

if(temp.start==NULL)

temp.start=t;

}

while(i!=NULL)

{

node *t=new node;

t->coeff=i->coeff;

t->deg=i->deg;

t->link=NULL;

temp.last->link=t;

temp.last=t;

i=i->link;

k++;

}

while(j!=NULL)

{

node *t=new node;

t->coeff=j->coeff;

t->deg=j->coeff;

t->link=NULL;

temp.last->link=t;

temp.last=t;

j=j->link;

k++;

}

temp.size=k;

return(temp);

}

void poly::display()

{

for(node *i=start;i!=NULL;i=i->link)

{

if((i->coeff>0)&&(i!=start))

cout<<"+";

cout<<i->coeff<<"X"<<"^"i->deg;

}

}

void main()

{

poly a,b,c;

clrscr();

cout<<"\n\tINPUT";

cout<<"\n\t***";

a.getpoly();

b.getpoly();

c=a+b;

cout<<endl;

cout<<"\n\tOUTPUT";

cout<<"\n\t****";

cout<<"\n\tfirst polynomial:";

a.display();

cout<<endl;

cout<<"\n\tsecond polynomial:";

b.display();

cout<<endl;

cout<<"\n\taddition polynomial:";

c.diplay();

getch();

}

Input:

enter the size:2

enter the coeffcint:5

enter the degree:2

enter the coeffcint:7

enter the degree:1

enter the size:2

enter the coeffcint:3

enter the degree:2

enter the coeffcint:3

enter the degree:1

Output:

first polynomial:5X^2+7X^1

second polynomial:3X^2+3X^1

addition polynomial:8x^2+10X^1

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • 7
    I think it's called `iostream`, not `iostream.h` – ForceBru May 10 '22 at 11:47
  • 3
    You seem to be copying code from a book (or other learning resource) that’s severely outdated. This won’t work. You’ll need to stop using that and find a different resource. I recommend checking out [The Definitive C++ Book Guide and List](https://stackoverflow.com/q/388242/1968). – Konrad Rudolph May 10 '22 at 11:48
  • 2
    you should compile, test, debug more often. Writing lots of code before doing it means you have to face big issues, writing only little code means compile,test and debug is much simpler – 463035818_is_not_an_ai May 10 '22 at 11:48
  • 1
    Back in the days of [cfront](https://en.wikipedia.org/wiki/Cfront), before there was a C++ standard, the header `iostream.h` provided input and output facilities. With the first C++ standard **in 1998** the header name became `iostream`. Sources that use `iostream.h` are a quarter of a century out of date. – Pete Becker May 10 '22 at 13:04
  • How do you get output, when there is a compilation error? Or is this the output, you should get with the program? – Sebastian May 10 '22 at 15:36

1 Answers1

0

Use #include <iostream> instead

timhpb
  • 320
  • 2
  • 4
  • yes but how can ı manage this code after iostream and conio (not .h) – boranzer May 10 '22 at 11:52
  • You probably should ask a new question about the new problem. Your question was about the error message. – drescherjm May 10 '22 at 12:11
  • 4
    @stackstack123421: There's no `` in standard C++, nor `clrscr`, nor `void main`. Whatever source you are using, it is **extremely** outdated. There are plenty of C++ programmers who were _born_ after your tutorial was created. – MSalters May 10 '22 at 12:36
  • @stackstack123421 To compile those sources use an old compiler for the mentioned operating systems (MS-DOS, OS/2 or Windows 3.1): https://en.wikipedia.org/wiki/Conio.h Also use the respective operating system to run your program. The question is, why would you do that? No irony, there are lots of reasons. If you intend to program for those operating systems, you can use newer compilers, too, e.g. for OS/2 or eComStation you could use gcc 9.2 from 2019 - it supports C++17 and even supports some C++20 features (https://github.com/bitwiseworks/gcc-os2). – Sebastian May 10 '22 at 15:46