Thread: C headerfiles into C++

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    50

    C headerfiles into C++

    How do you put C header files into C++ source code?

    thanks.

  2. #2
    Registered User
    Join Date
    May 2005
    Posts
    50
    I mean like, #include <conio.h> how do you translate that into a C++ #include

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It's the same.

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Yes. ALL of the standard C headers are included in the ANSI/ISO C++ language standard.

    To be up-to-date, you should add a leading 'c' and delete the '.h' like this:

    #include <math.h> /* This is C */
    #include <cmath> // This is C++

    I think you have to be in namespace std to use the C++ header names. (?)

    BTW - conio.h in NOT in either standard. So your compiler might not have it, although it is quite common. And, don't try <cconio>.
    Last edited by DougDbug; 05-20-2005 at 02:26 PM.

  5. #5
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Quote Originally Posted by DougDbug
    I think you have to be in namespace std to use the C++ header names.
    Yes, all of the standard functions in C are in the std namespace in C++.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including default headerfiles in custom headerfiles
    By Sentral in forum C++ Programming
    Replies: 7
    Last Post: 02-18-2006, 09:42 AM