Short answer
“File header” has two common meanings. In source code, it usually means a comment block at the top of a file that describes it. In a binary file format, it means the fixed bytes at the start of the file that describe what follows. Neither meaning is the same as a .h header file, although the word is shared.
A comment block at the top of a source file
Many teams start each source file with a short comment:
/*
* File: parser.cpp
* Purpose: reads settings from a config file
* Author: your name
* Date: 2026-11-26
*/
The compiler ignores comments. Their job is to help people understand the file, and some projects also keep license notices there.
The header of a binary file
Binary formats often begin with a fixed structure that a program reads first, so it knows how to parse the rest of the file. Two examples:
- PNG images start with an 8-byte signature. Its values, written in decimal, are 137, 80, 78, 71, 13, 10, 26 and 10. The chunks that describe the image follow it.
- WAV audio files start with a RIFF header: the four characters
RIFF, a size field, and the tagWAVE.
A C or C++ program reads these by opening the file and examining the first bytes. The exact layout depends on the format, so check its specification before writing a parser.
How it differs from a header file
| File header | Header file (.h) | |
|---|---|---|
| Where it appears | At the top of a file | A separate file, pulled in with #include |
| What it describes | The file, or the format of its contents | Declarations that other source files need |
| What the compiler does | Ignores the comment; a binary header is data that a program reads | Reads its declarations as part of each source file |
If you are writing C or C++ and need a place for declarations shared between files, you want a .h file. If you want a note about what a file does, put it in a comment at the top.