Why do some people write methods in header file ?
And what's the difference between writing a method in a procedure file and a header file?
Here's the code :
Work.h
#include <time.h>
void DoWork(int n)
{
clock_t t = clock() + n * CLOCKS_PER_SEC / 1000;
while(clock() < t);
}
Program.c
#include <stdio.h>
#include "work.h"
int main(void)
{
printf("Starting work\n");
DoWork(100);
printf("Work has finished\n");
}
Is there any difference between writing a method in a procedure file and header file or are they same?
Edit 1 : The only difference I know is if I write DoWork() in procedure file, then I have to compile the procedure file and then pass the object code, while compiling the main program.
Thanks.