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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Solving math puzzles3m 32s
-
(Locked)
Creating random numbers3m 42s
-
(Locked)
Working with time functions3m 54s
-
(Locked)
Sorting data4m 8s
-
(Locked)
Debugging your code2m
-
(Locked)
Using a debugger4m 53s
-
(Locked)
Writing your own header file2m 53s
-
(Locked)
Mixing multiple source code files4m
-
(Locked)
Challenge: Lotto simulation1m 18s
-
(Locked)
Solution: Lotto simulation2m 29s
-
(Locked)
-