I got another question in C programming. I followed an example in the Book "Programming in C" and wrote the following two source files:
main.c:
#include <stdio.h>
#include <stdlib.h>
int i = 5;
int main(void)
{
printf("%i ", i);
foo();
printf("%i\n", i);
return 0;
}
and foo.c:
extern int i;
void foo(void)
{
i = 100;
}
Problem arises when I compile 'gcc main.c foo.c':
main.c:9:3: warning: implicit declaration of function 'foo' is invalid in C99 [-Wimplicit-function-declaration] foo(); ^ 1 warning generated.
I found a work around by renaming foo.c to foo.h and include it as header in main.c. Is this a good way of making it work? How to make it work with foo.c ?