You can tell the compiler where to stop, certainly. There are four stages to building a program: preprocessing, compiling, assembling, and linking. You can go as far down the list as you need to. Usually, if you're building a library, or just compiling "part of" a program, then you stop at assembling and don't link.
In your library example, the file with the function in it would need #include <stdio.h>, 'cause that function uses printf, and printf needs stdio.h. The main program may or may not <stdio.h>; it wouldn't need it just for that function call.
You can look up the function header for printf, certainly; it's
Code:
int printf(const char * restrict format, ...);
However, it is illegal in C to declare this function yourself (yes even if you use the exact same declaration and intend to use the library function); use the stdio.h header instead.