Understanding the hardware of printf

后端 未结 5 508
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 05:42

I was wondering if there was any resources available online that explains what happens with something, like printf of C, that explains what\'s going on in the very low level

5条回答
  •  -上瘾入骨i
    2020-12-05 06:33

    The printf() takes multiple arguments (variable length arguments function). The user supplies a string and input arguments.

    The printf() function creates an internal buffer for constructing output string. Now, printf() iterates through each character of user string and copies the character to the output string. Printf() only stops at "%".

    "%" means there is an argument to convert(Arguments are in the form of char, int, long, float, double or string). It converts it to string and appends to the output buffer. If the argument is a string then it does a string copy.

    Finally, printf() may reach at the end of user sting and it copies the entire buffer to the stdout file.

提交回复
热议问题