Thread: include directive with header file

  1. #1
    Registered User
    Join Date
    Nov 2019
    Posts
    66

    include directive with header file

    Hello everybody

    I am having trouble with header files. I am specifically looking for resources on how to construct header files. The resources I have found just tell me what these files are used for.

    Code:
    #include<stdio.h>
    #include "other.h"
     
    int main(void)
    {
           
       return 0;
    }
    I just want to make simple header file. What should I have to put in header file

    I'm just not sure the structure and syntax to use with headers. Any help would be great. Thanks in advance.

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    719
    Quote Originally Posted by Player777 View Post
    Hello everybody

    I am having trouble with header files. I am specifically looking for resources on how to construct header files. The resources I have found just tell me what these files are used for.

    Code:
    #include<stdio.h>
    #include "other.h"
     
    int main(void)
    {
           
       return 0;
    }
    I just want to make simple header file. What should I have to put in header file

    I'm just not sure the structure and syntax to use with headers. Any help would be great. Thanks in advance.
    You don't "have" to put anything in a header file you create, if your program consists of only one .c file.

    If your program has multiple .c files with function definitions and function calls in different files, then you would put all the extern function declarations/prototypes in the header file along with other things such as struct declarations, global data extern declarations, though global variables should be avoided in most cases.

    A good book on the C Programming language would explain all of this in more detail, or taking a course from a qualified instructor.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 10-15-2018, 04:37 AM
  2. file name lenght for include directive
    By kpmkhaja in forum Windows Programming
    Replies: 12
    Last Post: 10-11-2010, 03:41 AM
  3. cant include libipq.h header file
    By rohit83.ken in forum C Programming
    Replies: 3
    Last Post: 04-04-2008, 02:41 AM
  4. Include(#directive) problems
    By ZooTrigger1191 in forum C++ Programming
    Replies: 1
    Last Post: 03-03-2003, 10:18 PM
  5. Where can i add a header file other than include directory
    By asdfasdfasdf in forum C++ Programming
    Replies: 4
    Last Post: 09-26-2002, 07:23 AM

Tags for this Thread