I’m new to C89, and it appears that you must declare a function before calling it. So this is unacceptable:
void foo() {
bar();
}
void bar() {
// do stuff
}
Because bar() is defined after foo() in the file. Is there any way to get around this? Do I need a header file?
Add a prototype:
For projects with multiple source code files, prototypes will typically be placed in header files and included in multiple source files; the implementation need only be specified in a single source file. The compiler just needs the prototype to be able to perform proper type-checking etc.