Where do I find the code of standardized functions?

4 months ago by printf("%s", name); to c/c_lang

For instance, I wanted to see how printf is written. I looked into the stdio.h file, but there, I could only find the function declaration, no definition.

thomasdouwes 11 points 4 months ago

There are multiple implementations, the one often found on linux is glibc, you can find the source code for that online. printf is going to be a small wrapper for vfprintf though, so that is where you will probably find what you are looking for

path: 0 24120411, hotness: undefined, score: 11, children: 1
akunohana 1 point 4 months ago

Thanks!

path: 0 24120411 24120513, hotness: undefined, score: 1, children: 0
avidya 4 points 4 months ago

Check out GLIBC, the standard libc implementation for GNU/Linux, or the easier to read, minimalist, alternative libc MUSL.

Bootlin, runs the Elixir Code Cross Referencer that lets you easily hop between files. For instance, Here is the code for printf in GLIBC.

path: 0 24145522, hotness: undefined, score: 4, children: 0
ghodawalaaman 1 point 4 months ago path: 0 24148296, hotness: undefined, score: 1, children: 0
c_lang
c_lang

@programming.dev

login for more options
1357
103
33

Welcome to the C community!

C is quirky, flawed, and an enormous success.
... When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.
... The only way to learn a new programming language is by writing programs in it.

© Dennis Ritchie

🌐 https://en.cppreference.com/w/c

go to feed...