C++ Programming

This is a discussion on C++ Programming within the C++ Programming forums, part of the General Programming Boards category; I wanted to know why when i insert a simple code in my dev c++ compiler, then i compile and ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    33

    Unhappy C++ Programming

    I wanted to know why when i insert a simple code in my dev c++ compiler, then i compile and run the code came up with errors,

    i'll put the code here:


    #include <iostream.h>

    int main()

    {

    cout<<"hello world!";

    return 0;

    }

    (this are the errors) i need to know how to fix it?


    it says 23 C:\My Documents\Dev-Cpp\Templates\main.cpp:1
    iostream.h: No such file or directory.

    C:\My Documents\Dev-Cpp\Templates\main.cpp
    [Warning] In function `int main()':

    7 C:\My Documents\Dev-Cpp\Templates\main.cpp
    `cout' undeclared (first use this function)


    (Each undeclared identifier is reported only once for

    C:\My Documents\Dev-Cpp\Makefile.win
    [Build Error] [Templates/main.o] Error 1
    Snoop

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    are you sure your iostream.h is in the include directory?
    nextus, the samurai warrior

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by nextus
    are you sure your iostream.h is in the include directory?

    Iam not sure if is in the include directory. How do i find this? Sorry but iam new to C++ programming.
    Snoop

  4. #4
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    try to omit the .h like this

    #include <iostream>
    Programming is a high logical enjoyable art for both programer and user !!

  5. #5
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    go find your dev-c++ directory and then there should be a folder named "include" and in it there should be a header file iostream.h?
    nextus, the samurai warrior

  6. #6
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by moemen ahmed
    try to omit the .h like this

    #include <iostream>
    I try #include <iostream> with the rest of the code and is still giving me the same errors.
    Snoop

  7. #7
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by nextus
    go find your dev-c++ directory and then there should be a folder named "include" and in it there should be a header file iostream.h?

    i check the file "include" and there no folder named "iostream.h" how should i add that folder to "include"? or is there another way to fix it?
    Snoop

  8. #8
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    you may find it in a folder named "..\devc++\include\g++"
    ans iostream.h is a file not a folder
    check it
    or simply do a search on your hard drive looking for "iostream.h" if you find it else place , copy it to the folder i mentioned
    Programming is a high logical enjoyable art for both programer and user !!

  9. #9
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    Is that the beta version? ver 5 I think they call it. The interface is nice, but I've yet to figure out some of the compiler errors on that baby.

    If you're using version 4, then reinstall it. If not, then download version 4 and try that one.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  10. #10
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by ronin
    Is that the beta version? ver 5 I think they call it. The interface is nice, but I've yet to figure out some of the compiler errors on that baby.

    If you're using version 4, then reinstall it. If not, then download version 4 and try that one.
    Yeah i think would need to uninstall dev c++ 5 beta 7 and install dev c++ 4.
    Snoop

  11. #11
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by moemen ahmed
    you may find it in a folder named "..\devc++\include\g++"
    ans iostream.h is a file not a folder
    check it
    or simply do a search on your hard drive looking for "iostream.h" if you find it else place , copy it to the folder i mentioned
    i did a search on my hard drive and i found "iostream" and i add it to my "c++ folder" because there were no g++. i think iam gonna uninstall dev c++ 5 beta 7 and install dev c++ 4 beta 5
    Snoop

  12. #12
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    iostream.h is NOT a standard header file anymore. It's good that you get these errors.

    You should:

    #include<iostream>

    cout, cin, etc. are now also in the std namespace. To access them do one of several things:

    type:

    using namespace std;

    before the rest of your code.

    or
    type
    std::cout (or std::cin , etc.) everytime cout (or cin, etc.) appears in your code

    or
    type

    using std::cout;

    before the rest of your code using cout (and similar for others)

    or

    define all of your functions which use cout, cin, etc. to be in the std namespace as well (not recommended)

    Code:
    namespace std
    {
        void MyFunction()
        {
            cout << "Blah";
        }
    }

  13. #13
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by Polymorphic OOP
    iostream.h is NOT a standard header file anymore. It's good that you get these errors.

    You should:

    #include<iostream>

    cout, cin, etc. are now also in the std namespace. To access them do one of several things:

    type:

    using namespace std;

    before the rest of your code.

    or
    type
    std::cout (or std::cin , etc.) everytime cout (or cin, etc.) appears in your code

    or
    type

    using std::cout;

    before the rest of your code using cout (and similar for others)

    or

    define all of your functions which use cout, cin, etc. to be in the std namespace as well (not recommended)

    Code:
    namespace std
    {
        void MyFunction()
        {
            cout << "Blah";
        }
    }

    Well thank you very much for clearing that out for me. i used other codes instead of <iostream> and they worked. i uninstall my dev c++ 5 beta 7 but iam gonna install it back again.
    Snoop

  14. #14
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    hmm...
    that's weird. even with using iostream.h, I would have expected it to compile, just with backwards warnings about iostream.h being antiquated. If what Poly posted still doesn't work, you may need to check if the directories are installed correctly.

  15. #15
    Registered User
    Join Date
    Feb 2003
    Posts
    33
    Originally posted by alpha
    hmm...
    that's weird. even with using iostream.h, I would have expected it to compile, just with backwards warnings about iostream.h being antiquated. If what Poly posted still doesn't work, you may need to check if the directories are installed correctly.

    i think that directories wasnt install correctly, and is int had a g++ file either. so i uninstall it and intalling it back again. thank you anywayz.
    Snoop

Page 1 of 4 1234 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21