How does printf work?

5

How does the code behind the function printf() of C work? I know what this function does, I want to know how it works.

    
asked by anonymous 04.08.2015 / 21:51

1 answer

5

Each compiler can use whatever code they like in their library as long as it does everything that is specified. And most provide the source code, so the best thing is to look there. Some places:

Note that the codes are often bad to read since they try to be optimized and not readable.

The function essentially makes a parse in the string sent, prints the normal characters, and defaults to specific functions when you have to replace a pattern with a value that will often be converted to string first. For printing depends on the operating system or even the hardware where it is running. You may need to write to a port or you may have to call an OS function, or you may need a more complex and specific solution.

    
04.08.2015 / 22:09