Suppose I have a code like this
foo.h
#pragma once #ifndef _HEADER #define _HEADER //code #endif foo.c
#include "header.h" //code main.c
#include "foo.h" int main() { return 0 } Why should I include foo.h in foo.c? It can still work without it.
foo.hwould declare the interface defined infoo.cthat other modules, likemain.c, will use. That would mean function prototypes, etc. By includingfoo.hintofoo.c, it will be a nice defensive check thatfoo.handfoo.care consistent. The compiler will throw a warning or error if they are not.