The origin of sprintf-style string formatting

The string formatting concept found in sprintf can be found in almost any language today (you know, strangling the string% s% d% f etc. and providing a list of variables to fill in their places).

Which one was langugage that had a library function or language construct that offered this functionality?

Please provide some link to the source to confirm your claim, so that we avoid pure speculation or guessing.

Hello

Robert

+4
source share
2 answers

Wikipedia has a fairly extensive history. This suggests that the printf C function originates in the BCPL write function.

+6
source

I would say that they all take their roots back to the BCPL. We used BCPL to program operating systems for the 6809 processor two decades ago, and it had a writef() function that took arguments like %i2 (equivalent to C %2d ).

C was based on a shortened version of BCPL and inherited a similar mechanism for formatting output, and I'm sure that all other instances picked it up from C after that.

I could be wrong, this will not be the first or last time, but I am sure that it is correct, given what I know about the BCPL language and its origin.

+5
source

All Articles