Friday, July 16, 2010

printf, sprintf, and stdout

stdout or standard output is the stream where an application writes its it. It is the text terminal that has initiated the application; but we have the chance to redirect the output into something else. printf writes its output into the stdout whereas sprintf writes its output into the memory, sprintf is more flexible in terms that it is faster and we can also write the data later into a text terminal. If you notice there is a parameter for sprintf that is a pointer to character, this is the string array that is allocated in memory, but printf is writes data directly into the output stream; that is why printf doesn't need an extra char*parameter

No comments:

Post a Comment