Thread: Header Files?

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    4

    Header Files?

    G'Day all,

    C newbie here.

    I just have a quick question about the #include files.

    Are they called headerfiles?

    For example: #include <stdio.h>

    What is that file? I know it has something to do with standard in/out put, but what is it exactly? Is it a function?

    And also, I've discovered that some of my newb programs need to involve more of these files (such as stlib.h, etc.). Is there a list of the ones I can use in my programs somewhere?

    I'm using Dev-C++.

    Cheers,
    Muz.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Muz View Post
    Are they called headerfiles?
    Headers, header files, or any other type of names like that, yes.

    Quote Originally Posted by Muz View Post
    For example: #include <stdio.h>

    What is that file? I know it has something to do with standard in/out put, but what is it exactly? Is it a function?
    stdio.h contains variables and functions pertaining to standard input and output for you to use in your code. It's how printf() and such can be used by your program without you writing it out yourself.

    Quote Originally Posted by Muz View Post
    And also, I've discovered that some of my newb programs need to involve more of these files (such as stlib.h, etc.). Is there a list of the ones I can use in my programs somewhere?
    http://en.wikipedia.org/wiki/C_standard_library

    And btw, welcome to cboard.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    4
    Thankyou very much! Extremely helpful!

    Is there a way to perhaps automatically include certain header files when starting up a new source file in Dev-C++ 4.9.9.2?

    Say I wanted to always have #include 'stdio.h', 'stdlib.h', and others at the top when I start a new program, how would I do that (if I can)?

    Cheers,
    Muz.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I don't use Dev-C++, so I can't help you with that. Check the manual or any relevant documents with regard to your IDE.

    You might do better having to manually create your programs from scratch a few times until you get used to which header file contains which items. Just a thought.

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Don't rely on your IDE too much, type them yourself.

  6. #6
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Muz View Post
    Thankyou very much! Extremely helpful!

    Is there a way to perhaps automatically include certain header files when starting up a new source file in Dev-C++ 4.9.9.2?

    Say I wanted to always have #include 'stdio.h', 'stdlib.h', and others at the top when I start a new program, how would I do that (if I can)?

    Cheers,
    Muz.
    In Dev-C++, go to Tools -> Editor Options -> Code. In the bottom pick Default Source and type in whatever you want. That should do the job..

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    To clarify, headers typically do not contain functions... at least not the actual code for those functions. The code is usually in a library that is linked to your object files to create the final executable. The headers typically will only contain prototypes for those functions which lets the compiler do its job of type checking. The exception for this is templated code (C++) which may (or may not) be contained within the header file.

    Seems like there have been several posts regarding header files in the last couple weeks.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  3. classes and header files
    By Drake in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2006, 07:12 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM