7

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?

  • You can often obtain this information directly via your distribution. It's easy with Debian/Ubuntu, for example. What is your distribution? – Faheem Mitha Oct 16 '15 at 8:32
  • It's Ubuntu 12.04 LTS – freddy Oct 16 '15 at 8:33
6

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).

  • 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. – freddy Oct 16 '15 at 8:21
  • 1
    It's the primary library of functions and definitions for C programs. It contains the function you are looking for scanf() – X Tian Oct 16 '15 at 8:34
  • 4
    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 – phk Oct 16 '15 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.