To create your own header file, place items from your source code, typically preprocessor directives but other definitions as well, into a separate file saved with the dot-h filename extension. Common items to include in a custom header file are function prototypes, constant expressions, macros, external variable declarations, typedefs, structure definitions, comments, and even other header files. When accessing a custom header file in C, use the include preprocessor directive but enclose the custom header in double quotes, not angle brackets.
- (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. …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.