Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
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
up vote 6 down vote accepted

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|improve this answer
    
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
    
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
3  
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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