This package makes the C formatted output routines (
fprintf et al.)
usable in C++ programs, for use with the
<string> strings and the
It allows to write code like
cerr << autosprintf ("syntax error in %s:%d: %s", filename, line, errstring);
cerr << "syntax error in " << filename << ":" << line << ": " << errstring;
The benefits of the autosprintf syntax are:
- It reuses the standard POSIX printf facility. Easy migration from C to C++.
- English sentences are kept together.
- It makes internationalization possible. Internationalization requires format
strings, because in some cases the translator needs to change the order of a
sentence, and more generally it is easier for the translator to work with a
single string for a sentence than with multiple string pieces.
- It reduces the risk of programming errors due to forgotten state in the
output stream (e.g.
cout << hex; not followed by
cout << dec;).