iostream.h problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fsunglim
    New Member
    • Jul 2006
    • 2

    iostream.h problem

    Hi,

    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.

    THX =P
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    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

    Comment

    • fsunglim
      New Member
      • Jul 2006
      • 2

      #3
      hi,

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

      thanx for the reply


      Code:
      #include <iostream.h>
      #include <stdlib.h>
      #include <time.h>
      
      // Define the greatest possible value:
      #define MAX_RANGE 100
      
      main ()
      {
        int counter=0;
        long value,input;
      
        srand ( time (NULL) );         // Initialize random generator
        value = rand()%MAX_RANGE+1;    // Get random between 1 and MAX_RANGE
      
        cout << "\nInsert a value between 1 and " << MAX_RANGE << " : ";
      
        do {
      
          cin >> input;                // Get user input
          counter++;                   // increase attempts counter
      
          if (value>input)             // is value grater than the input?
            cout << "Value is greater than " << input << ". Try again : ";
      
          else if (value<input)        // if not, is it less?
            cout << "Value is less than " << input << ". Try again : ";
      
          else {                       // else it is the correct number!
            cout << "That's right! Value was " << input;
            cout << "\nYou have needed " << counter <<" attempts.";
            }
      
        } while (value!=input);
        return 0;
      }

      Comment

      • dna5122
        New Member
        • Jul 2006
        • 12

        #4
        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:
        #include<iostre am>
        #include<cstdli b>
        #include<ctime>
        using namespace std;
        // Define the greatest possible value:
        #define MAX_RANGE 100
        ...

        Oh, please don't ever call C++ programs 'scripts', ever.

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Also even if it is C++ main should be

          Code:
          #include "stdlib.h"
          
          int main()
          {
            // Code statements here
          
            return EXIT_SUCCESS;
          }
          And in deed C++ cource files are not scripts.

          Comment

          • mireazma
            New Member
            • Aug 2008
            • 4

            #6
            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...

            Comment

            • QuannanHade
              New Member
              • Oct 2008
              • 9

              #7
              Please ignore this post - i submitted half-way through, refer to next post please
              Last edited by QuannanHade; Oct 1 '08, 12:05 PM. Reason: Please ignore this post - i submitted half-way through

              Comment

              • QuannanHade
                New Member
                • Oct 2008
                • 9

                #8
                As a new programmer (I literally started learning today) I am working on the traditional "Hello World" program,

                Code:
                #include <iostream.h>
                
                
                int main ()
                {
                    cout << "Hello World!\n";
                        return 0;
                }
                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 "PegAppInitiali ze(PegPresentat ionManager *)" 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

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Read reply #4, try the code and post your code here if you still have errors.

                  Comment

                  • QuannanHade
                    New Member
                    • Oct 2008
                    • 9

                    #10
                    I tried the code (now looking like this)

                    Code:
                    #include <stdlib.h>
                    
                    
                    int main ()
                    {
                        cout<<"Hello World!\n"
                        return 0;
                    }
                    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?

                    Comment

                    • boxfish
                      Recognized Expert Contributor
                      • Mar 2008
                      • 469

                      #11
                      I don't know why it can't find iostream.h, but your program should be:
                      Code:
                      #include <iostream>
                      
                      using namespace std;
                      
                      int main ()
                      {
                          cout<<"Hello World!\n";
                          return 0; 
                      }
                      You need to include iostream, use namespace std, and put a semicolon after the cout.

                      Comment

                      • QuannanHade
                        New Member
                        • Oct 2008
                        • 9

                        #12
                        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" ]
                        GCC ERRORS
                        [cannot specify -o with -c or -S and multiple compilations]

                        Thanks for your input though...

                        Comment

                        • newb16
                          Contributor
                          • Jul 2008
                          • 687

                          #13
                          Originally posted by QuannanHade
                          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?

                          Comment

                          • boxfish
                            Recognized Expert Contributor
                            • Mar 2008
                            • 469

                            #14
                            If you're using Dev-C++, look in Project -> Project Options -> Parameters tab for the arguments your program is passing to the compiler.

                            Comment

                            • QuannanHade
                              New Member
                              • Oct 2008
                              • 9

                              #15
                              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

                              Comment

                              Working...