# Question 1

What should go in header files? How to prevent a header file being included twice? Whats wrong with including more headers?
Â

Generally, a header (.h) file should have (A header file need not have a .h extension, its just a convention):

1.Â MacroÂ definitionsÂ (preprocessorÂ #defines). 2.Â Structure,Â union,Â andÂ enumerationÂ declarations. 3.Â AnyÂ typedefÂ declarations. 4.Â ExternalÂ functionÂ declarations. 5.Â GlobalÂ variableÂ declarations.

Put declarations / definitions in header files if they will be shared between several other files. If some of the definitions / declarations should be kept private to some .c file, don;t add it to the header files.

How does one prevent a header file from included twice?. Including header files twice can lead to multiple-definition errors.

There are two methods to prevent a header file from included twice

Method1

#ifndefÂ HEADER_FILE Â Â #defineÂ HEADER_FILE Â Â ...headerÂ fileÂ contents... #endif

Method2

A line like

#pragmaÂ once

inside a header file is an extension implemented by some preprocessors to help make header files idempotent (to prevent a header file from included twice).

So, what's the difference between #include <> and #include "" ?

The <> syntax is typically used with Standard or system-supplied headers, while "" is typically used for a program's own header files. Headers named with <> syntax are searched for in one or more standard places. Header files named with font class=announcelink>"" syntax are first searched for in the "current directory," then (if not found) in the same standard places.

What happens if you include unwanted headers?
You will end up increasing the size of your executables!

# Question 2

Is there a limit on the number of characters in the name of a header file?
Â

The limitation is only that identifiers be significant in the first six characters, not that they be restricted to six characters in length.