1

Possible Duplicate:
Where to find stdio.h functions implementations?

In C i have been using headers that contain prototypes and declarations of functions provided by the libraries, but where are functions like printf, scanf, etc. stored?

Where are they stored?

In which directory?

Why can't i find them? Are they stored as object files?

Community
  • 1
  • 1
Expert Novice
  • 1,943
  • 4
  • 22
  • 47
  • 1
    Are you looking for the declaration, source code, or executable code, of these library functions? – stakx - no longer contributing Aug 15 '11 at 18:51
  • I am not looking for source code. I want to know if these are stored as object files or executables, whichever be the case - where are they stored? – Expert Novice Aug 15 '11 at 18:53
  • 1
    The actual library implementations are stored in shared library files which are linked against your programs and loaded by the OS at runtime. The standard C library functions like printf are stored in /lib/libc.so on Linux/BSD and c:\windows\system32\msvcrt.dll on Windows. Is that what you mean? – James O'Doherty Aug 15 '11 at 19:01

4 Answers4

1

As everyone said, its int libc. You can search google for source code browser for the OS you are interested in, for linux I could find: http://lxr.linux.no/linux/

For netbsd, you can find printf and scanf here: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/?only_with_tag=MAIN#dirlist

hari
  • 9,439
  • 27
  • 76
  • 110
  • On many Unix-like systems, the math functions are in `libm`, not `libc`. (This causes a lot of confusion, since the linker can't find `sqrt()`, for example, unless you explicitly invoke the linker or compiler with `-lm`.) – Keith Thompson Aug 15 '11 at 20:19
  • @Keith Thompson: Thanks kaith. You are right but I, probably, am not getting your point here. What are you trying to convey? – hari Aug 15 '11 at 20:58
  • Just that the code that implements the math functions is often in libm, not in libc. (More precisely, in /usr/lib/libm.so, not /usr/lib/libc.so, or some other system-specific naming convention.) – Keith Thompson Aug 15 '11 at 21:06
  • @Keith Thompson: Agree. I never mentioned anything about math functions. I just wanted to show OP a way by searching in code browsers. Thanks. – hari Aug 15 '11 at 21:15
0

These functions are provided by the standard C library, often called libc.

In linux, you can find it under /lib/libc.so In Windows they call it C Run-Time Libraries.

Vinicius Kamakura
  • 7,665
  • 1
  • 29
  • 43
0

One place to check out is the section 3 of the manual. Then each individual function manual page lists the required header files and what additional libraries, if any, you need to link with.

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171
0

On Mac OS X, those functions are in stdio.h and is located in /usr/include. The library libc.dylib is in /usr/lib.

tny
  • 1
  • `libc.dylib` is a symbolic link to the actual system library on OS X - `libSystem.dylib`. –  Aug 16 '11 at 05:35