3

Where do i find the definition/body of the printf/scanf & other similar predefined commonly used functions (getch, clrsr ...etc) of "Borland C" ?

Johan
  • 74,508
  • 24
  • 191
  • 319
abhishek-23
  • 496
  • 3
  • 5
  • 15
  • 7
    Of the Borland implementation? Nowhere, it's closed source. But you can download e. g. the source of the GNU libc, that's probably even better (standards-conformant, significantly higher quality, etc.) –  Dec 29 '12 at 06:34
  • what's the name of the header that you must include to use this functions ? – user1824407 Dec 29 '12 at 06:34
  • 1
    They should be in the 'standard C library' that comes with the compiler, or the 'standard C library' that's already installed on the system. The header for `printf()` and `scanf()` etc is ``. – Jonathan Leffler Dec 29 '12 at 06:34
  • 2
    @JonathanLeffler : that's where the *declaration* would be, for sure - the OP is specifically asking for *definition*. Unless they include sources for the std library, it's likely not included with product. – ckhan Dec 29 '12 at 06:40
  • 1
    @JonathanLeffler Unless `printf()` is inlined, I don't think that's going to be true... –  Dec 29 '12 at 06:41
  • The compiled definition of the `printf()` function (for example) is going to be in the relevant library. The source body of the function is probably not available — period. If you need to get a program to compile, you need the compiled definition of `printf()` from the library. You don't need the source for `printf()` unless you're planning to modify its code — and people who are planning to do that don't need to ask this question. I double-checked that it was not the same person asking this question as [Borland 5.5 C Compiler not working](http://stackoverflow.com/q/14028520/15168). – Jonathan Leffler Dec 29 '12 at 06:46
  • Wasn't about Borland, but same concept: http://stackoverflow.com/questions/13350231/where-can-i-find-source-code-to-to-truly-understand-what-the-standard-function. As H2CO3 said though, you're not likely to come across the Borland source. – Corbin Dec 29 '12 at 06:53
  • Where's the `Standard C Library` located for borland or GNU gcc? `I wanted to know the core working of the standard function's (by observing their definition) like : How system fetches date from inner core system using time() ? What's happen's when printf is called ? ` Are the definition of above function's written in Assembly???? – abhishek-23 Dec 29 '12 at 15:31
  • @H2CO3: if "Borland C" refers to the command-line compiler, then you are right that the RTL source is not provided. But if it refers to the "Borland C++Builder" product instead, then it does include RTL source code. – Remy Lebeau Jan 28 '13 at 21:35

2 Answers2

6

You cannot.. You can just see the prototype of printf/scanf in the header file <stdio.h>

You can find it in the standard library which comes with whatever compiler you are using..

Raghu Srikanth Reddy
  • 2,703
  • 33
  • 29
  • 42
  • Where's the `Standard C Library` located for borland or GNU gcc? `I wanted to know the core working of the standard function's (by observing their definition) like : How system fetches date from inner core system using time() ? What's happen's when printf is called ?` Are the definition of above function's written in Assembly???? – abhishek-23 Dec 29 '12 at 15:37
  • 2
    Source code for glibc can be found here: http://www.gnu.org/software/libc/ However, be aware that it's NOT "easy to read" source. – Mats Petersson Dec 29 '12 at 21:02
  • And most of glibc is not writen in assembler, but a few small pieces are for performance reasons. Or because the code is not possible to achieve in C. – Mats Petersson Dec 29 '12 at 21:03
1

Probably you cannot see the source code of predefined functions like printf() and scanf() since they are already compiled file with extension of .lib the compiler just need the declaration of function and doesn't need exact source file they are link later by linker to produce .exe file.

Al Sweigart
  • 11,566
  • 10
  • 64
  • 92
mayur
  • 11
  • 1