C Question

This is a discussion on C Question within the C Programming forums, part of the General Programming Boards category; One prob i have is how you make your own header in C?...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    10

    C prob

    One prob i have is how you make your own header in C?
    Last edited by fastprogrammer; 11-14-2005 at 09:59 AM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Type text into a file. Generally the file is saved with an .h extension.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    10
    I see if that works.

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    As an aside, you would #include it like this:

    #include "my_header"

  5. #5
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    You mean:
    Code:
    #include "my_header.h"
    (C headers end in .h by convention)

  6. #6
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by cwr
    You mean:
    Code:
    #include "my_header.h"
    (C headers end in .h by convention)

    Absolutely that is what I meant. Thanks for the correction.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    10
    That make sence now.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    You would also want inclusion guards:
    Code:
    #ifndef HEADER_H
    #define HEADER_H 1
    
    /* header file code here */
    
    #endif
    This prevents bad things from happening if you include the header twice or in two different files.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    dwks,

    What is the point in adding advice to a 6 week old thread, especially given that the original poster hasn't posted anything since the last reply to this thread before yours?

    See the guidelines (number 5).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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