Where is `scanf` implementation source code?

6,042

It's in glibc library scanf.c source

glibc stands for GNU C Library. It is a C standard library implementation. It's not a part of the compiler, because you might have different implementations of it (like Microsoft C run-time for example) as well as different compilers (like clang).

Share:
6,042

Related videos on Youtube

Markus
Author by

Markus

Updated on September 18, 2022

Comments

  • Markus
    Markus over 1 year

    I want to find C source code for scanf implementation on Linux machine. Googling to find scanf implementation does not tell me the way to find it. I tried to find that source code from gcc source tree using ctags and cscope, but I could not find it. Can anybody please tell me where is scanf function definition, i.e. implementation source code?

    • Alen Milakovic
      Alen Milakovic over 8 years
      You can often obtain this information directly via your distribution. It's easy with Debian/Ubuntu, for example. What is your distribution?
    • Markus
      Markus over 8 years
      It's Ubuntu 12.04 LTS
  • Markus
    Markus over 8 years
    Thank you for quick answer! could you please elaborate why that source code is not included(?) in my gcc source tree? I don't know what glibc does(support) for my hello_world program.
  • X Tian
    X Tian over 8 years
    It's the primary library of functions and definitions for C programs. It contains the function you are looking for scanf()
  • phk
    phk over 8 years
    Just worth pointing out that other C standard libraries and therefore scanf implementations exist as well, e.g. uClibc: github.com/ffainelli/uClibc/blob/master/libc/stdio/_scanf.c