This is so that the code is included only once. For example, let's say you have three files: file1.h, file2.h, and file3.c.
file1.h is the following:
Code:
// file1.h
int var1, var2;
char var3, var4;
file2.h is the following:
Code:
// file2.h
#include "file1.h"
int var5;
finally, file3.c is the following:
Code:
// file3.c
#include "file1.h"
#include "file2.h"
// code here
If you did the above, then var1, var2, var3, and var4 would be defined twice, which is a bad thing. Using the #infdef/#define/#endif would keep this from happening.