[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppIofLib
instead of:
or, using printf():
The ''iof'' version is almost identical to the printf() version, but manipulates your standard streams, so it maintains all the advantages of streams over C's stdio printf/scanf functions:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppIofLib
(C++) iof (third party library)
The iof library greatly facilitates formatted output and input with STL streams, by providing a replacement for, or equivalent to, C's printf and scanf family of functions. It basically converts format strings of the type given to printf() and scanf() to equivalent calls on the STL streams. E.g. it allows you to write:
std::cout << iof::fmtr("Ground is %>s at z=%.2fs\n")
<< objName << zz;
instead of:
std::cout << "Ground is " << std::right << objName << " at z="
<< std::iof::precision(2) << std::fixed << zz
<< std::endl;
or, using printf():
printf("Ground is %>s at z=%.2f\n", objName, zz);
The ''iof'' version is almost identical to the printf() version, but manipulates your standard streams, so it maintains all the advantages of streams over C's stdio printf/scanf functions:
- type safety (no buffer overruns, undefined behavior, leaks etc)
- can handle ?objects (instances of class), not just ints, floats,etcetera.
- can use ?polymorphic nature of objects
- common interface for all types of streams (derived from STL streams).
External links
- iof home: iof
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
