printf()如何工作 [英] How does printf() works

查看:117
本文介绍了printf()如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道printf(stdio库函数)是如何工作的?是不是
这个depand在编译器上(我在Linix上使用gcc)


它是否使用一些缓冲区来存储所需的所有内容

打印并在程序结束时打印或其他内容。

解决方案

Dnia Sat,2008年3月22日04 :35:24 -0700(PDT)

Sanchit< sa ************ @ gmail.comnapisa3(a):


我想知道printf(stdio库函数)是如何工作的?

这个depand在编译器上(我在Linix上使用gcc)



嗯。这取决于实现(所以库不是编译器

本身)。


它是否使用一些缓冲区来存储所有的东西需要打印
并在程序结束时打印或其他内容。



你最好抓住glibc源并找到这个实现。

-

Tomasz bla Fortuna

jid:bla(at)af.gliwice.pl

pgp:0x90746E79 @ pgp.mit.edu

www: http://bla.thera.be


- ----开始PGP SIGNATURE -----

版本:GnuPG v2.0.7(GNU / Linux)

iD8DBQFH5PKhT6wvGJB0bnkRAucXAJ9MXo8HWUUBIAenKRAWW0 FKCHrW5ACgnzXR

2PyUKHQKgpmKh83NlFQjHKM =

= 2kU +

----- END PGP SIGNATURE -----


2008年3月22日星期六12:50:53 +0100,Tomasz bla Fortuna写道:


Dnia Sat,2008年3月22日04:35: 24 -0700(PDT)Sanchit

< sa ************ @ gmail.comnapisa ??(a):


>我想知道printf(stdio库函数)是如何工作的?这是对编译器的影响吗(我在Linix上使用gcc)



嗯。这取决于实现(所以库不是编译器

本身)。



它取决于库和编译器。例如,

编译器可以选择转换

(void)printf(Hello,world!\ n);

进入

(void)puts(Hello,world!);

表现相同,但工作方式不同。


3月22日下午4:50,Tomasz bla Fortuna< b ... @ thera.bewrote:


Dnia Sat,3月22日2008 04:35:24 -0700(PDT)

Sanchit< sanchitgupt ... @ gmail.comnapisa3(a):


我想知道printf(stdio库函数)是如何工作的?请问这个版本的编译器(我在Linix上使用gcc)



嗯。这取决于实现(所以库不是编译器

本身)。


它是否使用一些缓冲区来存储所有的东西需要打印
并在程序结束时打印或其他内容。



你最好抓住glibc源并找到这个实现。


-

Tomasz bla Fortuna

jid:bla(at)af.gliwice.pl

pgp:0x90746E79 @ pgp.mit.edu

www: http://bla.thera.be


signature.asc

1K下载



我已经这样做了..但没有太多描述


I want to know how does printf (stdio library function) works? Does
this depand on complier (I am using gcc on Linix)

Does it uses some buffer in which it stores all what needed to be
printed and in end of program it prints that or something else.

解决方案

Dnia Sat, 22 Mar 2008 04:35:24 -0700 (PDT)
Sanchit <sa************@gmail.comnapisa3(a):

I want to know how does printf (stdio library function) works? Does
this depand on complier (I am using gcc on Linix)

Uhm. It depends on implementation (so on the library not the compiler
itself).

Does it uses some buffer in which it stores all what needed to be
printed and in end of program it prints that or something else.

You''ll best just grab the glibc source and find this implementation.
--
Tomasz bla Fortuna
jid: bla(at)af.gliwice.pl
pgp: 0x90746E79 @ pgp.mit.edu
www: http://bla.thera.be

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFH5PKhT6wvGJB0bnkRAucXAJ9MXo8HWUUBIAenKRAWW0 FKCHrW5ACgnzXR
2PyUKHQKgpmKh83NlFQjHKM=
=2kU+
-----END PGP SIGNATURE-----


On Sat, 22 Mar 2008 12:50:53 +0100, Tomasz bla Fortuna wrote:

Dnia Sat, 22 Mar 2008 04:35:24 -0700 (PDT) Sanchit
<sa************@gmail.comnapisa??(a):

>I want to know how does printf (stdio library function) works? Does
this depand on complier (I am using gcc on Linix)

Uhm. It depends on implementation (so on the library not the compiler
itself).

It depends on both the library and the compiler. For example, the
compiler may choose to transform
(void) printf("Hello, world!\n");
into
(void) puts("Hello, world!");
which behaves the same, but works differently.


On Mar 22, 4:50 pm, Tomasz bla Fortuna <b...@thera.bewrote:

Dnia Sat, 22 Mar 2008 04:35:24 -0700 (PDT)
Sanchit <sanchitgupt...@gmail.comnapisa3(a):

I want to know how does printf (stdio library function) works? Does
this depand on complier (I am using gcc on Linix)


Uhm. It depends on implementation (so on the library not the compiler
itself).

Does it uses some buffer in which it stores all what needed to be
printed and in end of program it prints that or something else.


You''ll best just grab the glibc source and find this implementation.

--
Tomasz bla Fortuna
jid: bla(at)af.gliwice.pl
pgp: 0x90746E79 @ pgp.mit.edu
www:http://bla.thera.be

signature.asc
1KDownload

I have done that already.. but there is not much description


这篇关于printf()如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆