首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

怎样在include中查找printf函数的具体实现?解决思路

2012-03-03 
怎样在include中查找printf函数的具体实现?我在stdio.h中只看到原型声明,没有看到具体函数实现,不知道在哪

怎样在include中查找printf函数的具体实现?
我在stdio.h中只看到原型声明,没有看到具体函数实现,不知道在哪个文件中.


[解决办法]
如果你装的是VC,可以在下面的目录中找到:
%\Microsoft Visual Studio\VC98\CRT\SRC

STL和C标准库的源码都在里面,

----------------
/***
*printf.c - print formatted
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines printf() - print formatted data
*
*******************************************************************************/

#include <cruntime.h>
#include <stdio.h>
#include <dbgint.h>
#include <stdarg.h>
#include <file2.h>
#include <internal.h>
#include <mtdll.h>

/***
*int printf(format, ...) - print formatted data
*
*Purpose:
* Prints formatted data on stdout using the format string to
* format data and getting as many arguments as called for
* Uses temporary buffering to improve efficiency.
* _output does the real work here
*
*Entry:
* char *format - format string to control data format/number of arguments
* followed by list of arguments, number and type controlled by
* format string
*
*Exit:
* returns number of characters printed
*
*Exceptions:
*
*******************************************************************************/

int __cdecl printf (
const char *format,
...
)
/*
* stdout 'PRINT ', 'F 'ormatted
*/
{
va_list arglist;
int buffing;
int retval;

va_start(arglist, format);

_ASSERTE(format != NULL);

_lock_str2(1, stdout);

buffing = _stbuf(stdout);

retval = _output(stdout,format,arglist);

_ftbuf(buffing, stdout);

_unlock_str2(1, stdout);

return(retval);
}

[解决办法]
赵炯的linux0.11源代码 完全剖析 有详细的解释

热点排行