Code::Blocks
September 02, 2014, 11:13:57 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: The new Release 13.12 is out! You can download binaries for windows, mac and many major linux distros from  http://www.codeblocks.org/downloads/26 .
 
   Home   Help Search Login Register  :: WebsiteWiki  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: iostream.h: No such file or directory  (Read 8020 times)
xcf
Guest
« on: February 01, 2006, 08:58:34 am »

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]
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]

Logged
polygon7
Advanced newcomer
*
Offline Offline

Posts: 104


WWW
« Reply #1 on: February 01, 2006, 09:25:37 am »

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

best regards,
p7
 Free open source UML modeling tool: ArgoUML
tiwag
Developer
Lives here!
*****
Offline Offline

Posts: 1196


sailing away ...


WWW
« Reply #2 on: February 01, 2006, 12:14:57 pm »

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;
}

do a favour yourself and buy an ACTUAL C++ book !
burn your old book
Logged
Michael
Lives here!
****
Offline Offline

Posts: 1608


« Reply #3 on: February 01, 2006, 12:25:18 pm »

Hello,

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

Best wishes,
Michael
Logged

Ceniza
Developer
Lives here!
*****
Offline Offline

Posts: 1442



WWW
« Reply #4 on: February 01, 2006, 01:22:44 pm »

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.
Logged
tiwag
Developer
Lives here!
*****
Offline Offline

Posts: 1196


sailing away ...


WWW
« Reply #5 on: February 01, 2006, 01:50:59 pm »

conio.h is a non-standard header file.
...
discuss that stuff in news:comp.lang.cpp plz
Logged
Ceniza
Developer
Lives here!
*****
Offline Offline

Posts: 1442



WWW
« Reply #6 on: February 02, 2006, 02:03:32 am »

tiwag: I don't get it, what's your point? I was just naming problems with that source code, and using conio.h is one of those.

He maybe comes from Turbo C++ (at least that happened to me), so it's time to wake up and realize many things have changed since the 80's. It's somehow part of the learning process Smiley
Logged
Ceniza
Developer
Lives here!
*****
Offline Offline

Posts: 1442



WWW
« Reply #7 on: February 02, 2006, 06:32:42 pm »

Well, I got tiwag's answer in PM and it's right that MinGW comes with a conio.h, but it's a reduced version of it.

If you have plans to use conio.h in the meanwhile I suggest you trying the one Dev-C++'s ppl was working in a long time ago which can be found here.

It provides some extra functions, like clrscr().

The idea would be to "merge" the .c and .h files so it wouldn't require anything else than a conio.h.
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!