C語言的基本函式

2009-03-29 4:14 am
請問我想看一下
一些library已經幫我們寫好的內部函式
比如:
stdio 中include進來的printf scanf

內的含世到底是怎麼寫的


請給我網站 或是
教學 blockcode裡面要如何去看

如果有整理好的電子檔能寄給我的話
就太好了!
更新1:

Fine, you can just reply me with English.

更新2:

有答案的人麻煩儘快告知 這樣才不會點數又送不去TT 被記一筆

回答 (2)

2009-04-01 5:22 pm
✔ 最佳答案
Can I answer this in English?? I have problem typing Chinese here.

2009-04-01 09:22:02 補充:
The following is mainly in the unix world but windows has its own counter parts and will be more or less the same.

For printf or scanf, these are wrappers. If you look into /usr/include/stdio.h, all these are redefined as __P. That is the generic entry point for all these IO routines. Most of these are handled by other system calls (note that printf and scanf are just library calls not system calls). These library calls (printf and scanf) are inside /usr/lib/libc.a (the .so version is the dynamic library just like .dll in windows).

If you want to see the code for these routines, you will have to download the source of the target system or find a book describing these routines in detail. In linux, different favor or version may have slightly different code (not likely for printf but very likely for others). Different linux will have different ways to download the code, RedHat will use SRPMs and Ubuntu you will have to apt-get (or dpkg).

Books that describe this in detail:

1. Lion's Commentary on Unix 6th Edition by John Lions
2. Design of the UNIX Operating System by Bech

Also, these code will call on more fundamental system calls. I don't know if you really want to get into all the details. However, if you do, the following book may help you.

The Design and Implementation of the 4.4 BSD Operating System by by Marshall Kirk McKusick

If you prefer to stay in the programming part (not the operating system part), the classic book of
The C Programming Language by Kernighan and Richie
will do just fine. There is a chapter describing how IO works (not very detail).

Have fun.

2009-04-01 09:25:36 補充:
For windows, you cannot see what's going on inside. All source codes belong to Microsoft.
2009-03-29 4:57 am
內容是存在編譯器的程式資料夾內,是 h 標頭檔案,假如你有安裝編譯器,就可以自行開啟。


收錄日期: 2021-04-27 17:16:49
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090328000016KK09482

檢視 Wayback Machine 備份