[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
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



last edited (November 28, 2006) by bilderbikkel, Number of views: 2092, Current Rev: 7 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.