From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Writing your own header file

Writing your own header file - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Writing your own header file

- (Instructor) Here is a silly little program. It has a few includes, defines, plus a structure. It doesn't generate any output so the stdio.h header isn't included. This code is more for demo purposes, but pretend that it represents a huge program, one that goes on and on. Usually, when you get a lot of pre-processor directives, or you have a large program with several source code files, you can abbreviate your code and eliminate redundancies by creating your own header file. For example, here is the same silly code but with several of the items removed. Instead, you see a single include directive at line 1 with a file name in double quotes. The double quotes direct the compiler to look in the same directory as the source code file for a header named "05_07-header2.h". The contents of that file are inserted into this source code at that point. And here are the contents. You see the includes, the defines, and the structure definition from the first exercise file. These are typical…

Contents