今天突然心血来潮,想一睹c的输入输出库函数具体实现,于是便搜寻,最后得知所有的库函数源代码都位于glibc中,只需要下载glibc包,然后解压即可。
具体下载网址:http://ftp.gnu.org/gnu/libc/
基本输入输出函数我找了半天,最终还是找到位置了,位于glibc文件夹的stdio-common子文件夹中,下面为scanf的源代码:
int
__scanf (const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = _IO_vfscanf (stdin, format, arg, NULL);
va_end (arg);
return done;
}
当然这只是其中某一函数,如要查看其他函数,就下载glibc库吧
当然这是在linux下进行的,不知道windows有没有对应的库。