I am new to C and have recently started learning about header files and noticed that a lot of programmers declare functions in .h
files
header.h
#ifndef HEADER_H
#define HEADER_H
int func(int a);
int foo(char *s);
And i have noticed that these functions are not defined in the .h
files either.
Instead they are defined in a .c
file normally in the same directory as the .h
file.
This seems odd to me and i am a bit confused as to why this occurs.
As far as i know, would it not be okay to define & declare the functions in the .h
file and use a header file guard so the function is not #include
d twice in a program, why define it in a seperate .c
file ?