I study C and I noticed that I can't find the implementation file for some header files like, for example, stdio.h
which is a library which contains a lot of input/output functions, like printf
. Where can I find its implementation?
In Ubuntu, which your original question indicated you're using, the “root” stdio. h file is in /usr/include .
h> You tell the compiler to search for the file 'stdio. h' in the standard library folders only . but when you write #include”stdio. h” You mean that search the file 'stdio. h' in the standard library functions as well as in the current folder where you are working .
The stdio. h header defines three variable types, several macros, and various functions for performing input and output.
In the following example, we are using the #include directive to include the stdio. h header file which is required to use the printf standard C library function in your application.
Download one of these:
Or, even better, download several of these and compare their implementations. Of course, these are likely doing a lot of things different compared to your particular standard library implementation, but would still be quite interesting for e.g. non-platform-specific functionality such as sprintf.
You need to find the source code for a C standard library like glibc: http://www.gnu.org/s/libc/
You can download the source here: http://ftp.gnu.org/gnu/glibc/ It contains source for all the library functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With