Question: consider the following code, which causes a weird behavior:

foo.h
-----

```
#ifndef FOO_H
#define FOO_H

void foo();

#endif

```

foo.c
-----

```
#include <stdio.h>
// NOTICE - foo.h is not included!

void foo()
{
    printf("foo!\n");
}

```

main.c
------

```
#include "foo.h"

int main()
{
    foo();
    return 0;
}

```

running this code I get in the console: `foo!`

what bugs me here is that I expected that `main.c` would not be familiar with the implementation of `foo()`, since `foo.h` is not included in `foo.c`, and hence `foo()` should be an inner function in `foo.c`. It happened to me both when I ran it in VS2010 and when I compiled an exe using gcc (on windows).
can someone explain this phenomenon? I thought about it and I have no idea why it happens. thanks.

Answer: 
The header file is declaring the function, so when compiling main.c the compiler knows the function signature to validate against. When compiling foo.c, it doesn't need to be declared, as it is the declaration of the function. It is up to the linker to see if there are any unresolved symbols, which there aren't in this case, so all is good, and also why you're seeing this work.
What will happen if there was another function(test.c) included in the above question. 

**foo.h**

```
#ifndef FOO_H
#define FOO_H

void foo();

#endif

```

**foo.c**

```
#include <stdio.h>
// NOTICE - foo.h is not included!

void foo()
{
    printf("foo!\n");
}

```

**test.c**

```
#include <stdio.h>  
void foo()
{
    printf("foo!\n");
}

```

**main.c**

```
#include "foo.h"

int main()
{
    foo();
    return 0;
}

```