Some really quick questions on header files

This is a discussion on Some really quick questions on header files within the C++ Programming forums, part of the General Programming Boards category; OK. I have been wondering. can you do Code: #include <iostream> or does it have to be Code: #include <iostream ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    24

    Some really quick questions on header files

    OK. I have been wondering.

    can you do
    Code:
    #include  <iostream>
    or does it have to be
    Code:
    #include <iostream.h>
    ?

    Is it
    Code:
    #include <conio.h>
    or
    Code:
    #include <conio.c>
    ?

    Thanks
    #include <iostream.h>
    int main()
    {
    cout<<"Hello";
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    24
    oh, one more thing. Not header files but similar thing.

    does it matter if you do
    Code:
    int main()
    or
    Code:
    void main()
    ?
    #include <iostream.h>
    int main()
    {
    cout<<"Hello";
    return 0;
    }

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Conforming to the C++ standard, it's

    #include <iostream>

    int main()

    and it's up to you with conio as there's no standard header with that name.

  4. #4
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Re: Some really quick questions on header files

    Some experts say that main should return something, hence the int in front of it.......I don't know a lot about this, but I know that prelude knows the reason behind this.......I thnk that prelude gave a whole explanation about it a while back, search around the board and you "shall" find.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    24
    but in the tutorials on this site it uses iostream.h

    it also uses a header called conio.h

    (they're both in the 5th tutorial about switch and case)
    #include <iostream.h>
    int main()
    {
    cout<<"Hello";
    return 0;
    }

  6. #6
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Originally posted by quentin
    but in the tutorials on this site it uses iostream.h

    it also uses a header called conio.h

    (they're both in the 5th tutorial about switch and case)

    Maybe when they made the tutorials things in C++ weren't under namespaces. The reason for this is that this reduces some errors when you code or something. You can also make your own namespaces. Look up something on Namespaces for further details.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    24
    iostream.h works for me btw

    but conio.h didn't so I omitted it and it worked fine
    #include <iostream.h>
    int main()
    {
    cout<<"Hello";
    return 0;
    }

  8. #8
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    C++ was standardised in 1998, as this isn't that long ago there is plenty of documentation (tutorials, books, etc) that use the pre-standard headers. Also compilers will normally support the old headers, however this may not always be the case so if you try to compile your code in 10 years time using the iostream.h file don't be suprised if it doesn't work.

    As I've already stated, there's no standard way to include a 'conio' file. It's up to the implementor and could be called anything.

    main should return an int as a return value to the enviroment in which the program was run. This enviroment can then test this return value and act accordingly.

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    24
    i think I understand
    #include <iostream.h>
    int main()
    {
    cout<<"Hello";
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Novice question on header files
    By hern in forum C++ Programming
    Replies: 1
    Last Post: 07-30-2005, 10:11 AM
  2. What /what not to put in header files
    By Just in forum C Programming
    Replies: 1
    Last Post: 12-14-2002, 09:45 AM
  3. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  4. Header files
    By Jez_Master in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2002, 07:56 AM
  5. quick question about header files
    By Kirstin in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2001, 11:21 AM

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