Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 yesterday
    
It's Ubuntu 12.04 LTS – freddy yesterday

1 Answer 1

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 yesterday
    
It's the primary library of functions and definitions for C programs. It contains the function you are looking for scanf() – X Tian yesterday
2  
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 yesterday

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.