$ cat test.c
#include <stdio.h>
#include "test.h"
int foo(int i)
{
return i;
}
int main()
{
printf("%i\n", foo(2));
return 0;
}
$ cat test.h
int foo(int i);
$ gcc -Wall –pedantic test.c
$
#include <stdio.h>
#include "test.h"
int foo(int i);
int foo(int i)
{
return i;
}
int main()
{
printf("%i\n", foo(2));
return 0;
}
example:
I know what this is doing, what I don't get is why this is desired, when the first example works fine?
Kind of a short question for a thread, but I couldn't figure out where else to put it.
Bonus Question! :)
If you declare a prototype for a local function, is it good practice to have both a header prototype, and local?
Example: