471,071 Members | 1,000 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

iostream.h problem


i'm a c++ nub, i got a simple file in.cpp which i uses .net to compile but it gives me an error:

"fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory".

may i noe where do i get the iostream.h file so tat i can attach it to the header.

Jul 28 '06 #1
22 30818
9,065 Expert Mod 8TB
Should just be a case of making sure you have the include path to iostream.h in your compiler include paths.

iostream.h should have been distributed with Visual Studio
Jul 28 '06 #2

below is the c++ script which i try to run and its the script tat given me the error.

thanx for the reply

Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  5. // Define the greatest possible value:
  6. #define MAX_RANGE 100
  8. main ()
  9. {
  10.   int counter=0;
  11.   long value,input;
  13.   srand ( time (NULL) );         // Initialize random generator
  14.   value = rand()%MAX_RANGE+1;    // Get random between 1 and MAX_RANGE
  16.   cout << "\nInsert a value between 1 and " << MAX_RANGE << " : ";
  18.   do {
  20.     cin >> input;                // Get user input
  21.     counter++;                   // increase attempts counter
  23.     if (value>input)             // is value grater than the input?
  24.       cout << "Value is greater than " << input << ". Try again : ";
  26.     else if (value<input)        // if not, is it less?
  27.       cout << "Value is less than " << input << ". Try again : ";
  29.     else {                       // else it is the correct number!
  30.       cout << "That's right! Value was " << input;
  31.       cout << "\nYou have needed " << counter <<" attempts.";
  32.       }
  34.   } while (value!=input);
  35.   return 0;
  36. }
Jul 29 '06 #3
Several things to note here. You mentioned .NET - did you create this project as a .NET project or as a console application? It should be a console appliation. I guess you just meant you are using Visual Studio.NET.

I don't know about the latest versions of C++ from MS but the .h header files have been deprecated for quite some time and could have been removed. Somehow I doubt they'll ever stop shipping the old .h files as that would break backwards compatibility. Although Banfa is probably right, I wonder how that include directory could have been dropped?

You could also try dropping the .h extension on all header files that you didn't create yourself like this:
using namespace std;
// Define the greatest possible value:
#define MAX_RANGE 100

Oh, please don't ever call C++ programs 'scripts', ever.
Jul 29 '06 #4
9,065 Expert Mod 8TB
Also even if it is C++ main should be

Expand|Select|Wrap|Line Numbers
  1. #include "stdlib.h"
  3. int main()
  4. {
  5.   // Code statements here
  7.   return EXIT_SUCCESS;
  8. }
And in deed C++ cource files are not scripts.
Jul 29 '06 #5
Hi. I have the same problem: *unable to open include file 'IOSTREAM.H'*
I've checked the path - the file is there. I'm curious to find out what's the problem.
I've also tried without '.h'. Nothing changed...
Aug 28 '08 #6
Please ignore this post - i submitted half-way through, refer to next post please
Oct 1 '08 #7
As a new programmer (I literally started learning today) I am working on the traditional "Hello World" program,

Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  4. int main ()
  5. {
  6.     cout << "Hello World!\n";
  7.         return 0;
  8. }
and unfortunately I am coming up with the same error, and when I try without the ".h" extension I receive even more errors ranging from
iostream: No such file or directory. and `cout' undeclared (first use this function) to
L2310 (W) Undefined external symbol "PegAppInitialize(PegPresentationManager *)" referenced in "cppeg_add"

All I really need is a way to get around the iostream problem, and i am wondering if a few things might work...
1) Try to program on an XP system, it may be a Vista thing
2) Find an alternate file to use
3) See if my code is a little off (in that case i will find a better guide)...

If you could back me up (as in check my work and possibly tell me if one (or all) of the solutions are worthless i would appreciate it greatly
Oct 1 '08 #8
13,262 8TB
Read reply #4, try the code and post your code here if you still have errors.
Oct 1 '08 #9
I tried the code (now looking like this)

Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  4. int main ()
  5. {
  6.     cout<<"Hello World!\n"
  7.     return 0;
  8. }    
and according to the error messages there are no problems on any line, however there are still the errors of
[C3305 (F) Invalid command parameter "LC \PROGRA~1\Dev-Cpp\lib"] and
a GCC error of [cannot specify -o with -c or -S and multiple compilations]
thankyou for pointing out that post to me, but do you have any ideas about this?
Oct 2 '08 #10
469 Expert 256MB
I don't know why it can't find iostream.h, but your program should be:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  3. using namespace std;
  5. int main ()
  6. {
  7.     cout<<"Hello World!\n";
  8.     return 0; 
  9. }
You need to include iostream, use namespace std, and put a semicolon after the cout.
Oct 2 '08 #11
Thanks (i didnt see the semi-colon bit, it must've slipped my mind) however that doesnt work either - even tried using iostream.h and stdlib.h instead but none of them works... I'm going to get on the XP computer and see if that fixes the problem... Oh, and in case you were wondering the errors are the exact same two...

[C3305 (F) Invalid command parameter "LC \PROGRA~1\Dev-Cpp\lib" ]
[cannot specify -o with -c or -S and multiple compilations]

Thanks for your input though...
Oct 2 '08 #12
687 512MB
I[C3305 (F) Invalid command parameter "LC \PROGRA~1\Dev-Cpp\lib"] and
a GCC error of [cannot specify -o with -c or -S and multiple compilations]
thankyou for pointing out that post to me, but do you have any ideas about this?
So what do you run in case of gcc - I mean command line arguments? Did you try to look at command line and find what causes the problem?
Oct 2 '08 #13
469 Expert 256MB
If you're using Dev-C++, look in Project -> Project Options -> Parameters tab for the arguments your program is passing to the compiler.
Oct 2 '08 #14
Thanks for all that... for some reason Dev-C++ doesn't like 'cout', it worked fine yesterday, but today and on Wednesday it doesn't know what the cout command is ("cout undefined" etc.)...
I have a feeling I just got a crappy version (I originally found it while looking for programs to run on my calculator (Classpad 330), and i found "CASIO SDK" using Dev-C++ as a basis to work from... I was really excited when i read the description for SDK, as I thought this is perfect to learn C++, but i have a feeling that the Dev-C++ has been modified dramatically (even when run without the SDK)

I checked in the Parameters tab and nothing is being passed (the whole thing is blank (probably the problem) thought this might be how im running the program... at start of a project it asks the question "What will the format be?", Classpad file, Windows file, Classpad and Windows, Blank. I have been choosing blank as the other two just fill up the first page with automatically written code
Oct 2 '08 #15
849 Expert 512MB
In order to utilize "cout" as "cout", you need to have the line "using namespace std;" (semicolon matters) at the top of your file near the includes. Otherwise, you need to declare "cout" as "std::cout". As to the iostream issues, I'm not sure if Dev-C++ actually comes with the headers. I know they're not installed by default on Windows...Not entirely sure, though.
Oct 3 '08 #16
even using namespace std; doesn't do anything, the old GCC error just keeps popping up, and i found it wasnt a compatibility problem as i hoped, for the same problems occur on XP...
Oct 3 '08 #17
849 Expert 512MB
Search your computer for iostream.h, looking in hidden files and folders and system files and folders (options in the Windows search dialog). If nothing appears, then you need to install the header files.
Oct 3 '08 #18
I've found It (was in a folder containing Dev-C++ [C:\Program Files\Dev-Cpp\include\c++\backward]) and now i just want to know how do i get the program to find it? Dev-C++ obviously knows where it is, but wont search there...
Oct 4 '08 #19
849 Expert 512MB
Somewhere in Dev-C++, there should be an option to set include paths (I've never used it, but look for something like Global Options/Tools->Options, Preferences, etc). Make sure that folder is in the list. If that doesn't work...I'm out of ideas, short of switching compilers.
Oct 4 '08 #20
just to show how noob-ish i am... where are the global settings? also -what version are you using?
Oct 4 '08 #21
469 Expert 256MB
Tools -> Compiler Options -> Directories tab.
Oct 4 '08 #22
Ok that worked, there was no problem with iostream, but now the gcc error and such are back... just not my luck eh?
Oct 4 '08 #23

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

19 posts views Thread by ernst.stiegler | last post: by
7 posts views Thread by S. Nurbe | last post: by
13 posts views Thread by Winbatch | last post: by
4 posts views Thread by luke.yolanda | last post: by
1 post views Thread by lars.uffmann | last post: by
12 posts views Thread by NOO Recursion | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.