This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Where is the source-code of prinf & scanf

After having some trouble with scanf & printf
(scanf receives 0x0D and convertes this to 0x0A)
(printf attaches CR to \n)

i ask myself: where's the Sourcecode of all this function's?
Printf & scanf sin, cos and all this stuff are library-functions.
Can they be changed, it is useful to change them?
Can i learn something for example how sin is computed?

Of course i've learned from this: now i use my own my_putchar & my_getkey when transmitting/receiving singele binary char's.

  • In the keil/lib folder there are some source files.Have a search.It is surely can be modified as you need.These are not parts of the C language standard,just extensions.

  • "In the keil/lib folder there are some source files."

    True - but not printf nor scanf.

    The provided files are documented in the Manual:

    http://www.keil.com/support/man/docs/ca/ca_lib_source.htm

    These are the only ones that should need customisation!

    If you really want some source, take a look at an Open-Source compiler like GCC...

    "These are not parts of the C language standard, just extensions."

    No, that's not quite true.
    Although not actually part of the language, the requirements of the standard library - including printf and scanf - are part of the standard!

  • "it is useful to change them?"

    Unlikely.

    More sensible, as has been said to you several times before, is to not use them at all but write your own functions to your own specific requirements!

  • "More sensible [...] is to not use them at all but write your own functions to your own specific requirements!"

    I agree. The printf family generally means a large chunk of lib code that will be linked to your system. Generally you will use but a few cases of formatted output or input, and that can generally be written in smaller C functions. In a few cases, it makes sense to use them, but when you need fast and small code, specific functions are a better option.