User forums > General (but related to Code::Blocks)

iostream.h: No such file or directory

(1/2) > >>

xcf:
exusmi of my english
make program

--- Code: ---[b]
#include <iostream.h>
#include <conio.h>
#include <math.h>
void main()
{
 clrscr();
 const int n=5;
 int a[n],c[n],i,x,h;
 double k;
 cout<<"\n vvdite masiv";
 for(i=0;i<n;i++)
        {
        cin>>a[i];
        }
        k=0;h=0;
 for(i=0;i<n;i++)
        {
                k=i%2;
                if (k==1) cout<<a[i]<<"\n";
                else {c[h]=a[i];h+=1;}
        }
 for(i=0;i<h;i++)
 cout<<"\n"<<c[i];
 getch();
}[/b]
next errors
[b]

--- End code ---
C:\9.c:1:22: iostream.h: No such file or directory
C:\9.c: In function `main':
C:\9.c:12: error: `cout' undeclared (first use in this function)
C:\9.c:12: error: (Each undeclared identifier is reported only once
C:\9.c:12: error: for each function it appears in.)
C:\9.c:13: error: `cin' undeclared (first use in this function)
C:\9.c:5: warning: return type of 'main' is not `int'
C:\9.c:25:2: warning: no newline at end of file
Process terminated with status 1 (0 minutes, 1 seconds)
5 errors, 2 warnings[/b]

polygon7:
Hi,
change:

--- Quote ---#include <iostream.h>
--- End quote ---
to
--- Quote ---#include <iostream>
--- End quote ---
and add below includes:
--- Quote ---using namespace std;
--- End quote ---
(or change all cout's and cin's to std::cout/cin). This should help.

tiwag:

--- Code: ---#include <iostream>
#include <conio.h>
//#include <math.h>
using namespace std;
int main() {
    //clrscr();
    const int n = 5;
    int a[ n ], c[ n ], i, h;
    double k;
    cout << "\n vvdite masiv";
    for ( i = 0;i < n;i++ ) {
        cin >> a[ i ];
    }
    k = 0;h = 0;
    for ( i = 0;i < n;i++ ) {
        k = i % 2;
        if ( k == 1 ) cout << a[ i ] << "\n";
        else {
            c[ h ] = a[ i ];h += 1;
        }
    }
    for ( i = 0;i < h;i++ )
        cout << "\n" << c[ i ];
    getch();
    return 0;
}

--- End code ---

do a favour yourself and buy an ACTUAL C++ book !
burn your old book

Michael:
Hello,

Here you can find some suggestion on good C++ books.

Best wishes,
Michael

Ceniza:
conio.h is a non-standard header file.

You already commented clrscr() and getch() doesn't work either 'cause it's part of conio.

C++ states you should include the C header math.h this way: #include <cmath>

Everything else seems to be fine.

Navigation

[0] Message Index

[#] Next page

Go to full version