Definition/body of the printf & scanf function in C
18,253
Solution 1
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..
Solution 2
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.
Related videos on Youtube
Author by
abhishek-23
Updated on June 04, 2022Comments
-
abhishek-23 almost 2 years
Where do i find the definition/body of the printf/scanf & other similar predefined commonly used functions (getch, clrsr ...etc) of "Borland C" ?
-
Admin over 11 yearsOf 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.)
-
Jonathan Leffler over 11 yearsThey 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()
andscanf()
etc is<stdio.h>
. -
ckhan over 11 years@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.
-
Admin over 11 years@JonathanLeffler Unless
printf()
is inlined, I don't think that's going to be true...
-
-
abhishek-23 over 11 yearsWhere'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???? -
Mats Petersson over 11 yearsSource code for glibc can be found here: gnu.org/software/libc However, be aware that it's NOT "easy to read" source.
-
Mats Petersson over 11 yearsAnd 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.