Interview Question

What is header file?

Headers share declarations and macros between translation units.

💡 Concept ✅ Quick Revision ⚙ C

Answer

A header file contains declarations and macro definitions intended for inclusion by preprocessing. • The `#include` directive replaces the directive with the header’s preprocessing tokens. • Standard headers declare library interfaces such as printf and malloc. • Project headers should use guards or `#pragma once` where supported to prevent harmful repeated inclusion.

💡 C Example

#ifndef MATH_HELPERS_H #define MATH_HELPERS_H int square(int value); #endif

⚡ Quick Revision

Headers share declarations and macros between translation units.