SoDaFormat-1.0.0-main:f160581  1.0.0
FormatExample.cxx
Go to the documentation of this file.
1 #include <SoDaFormat/Format.hxx>
2 #include <iostream>
3 
4 int main() {
5  SoDa::Format sft("Avogadro's number: %0\n");
6 
7  // Print Avogadro's number the way we all remembered from high school.
8  double av = 6.02214076e23;
9  std::cout << sft.addF(av, 's');
10 
11  // But all that 10^23 jazz is the result of the evil CGS system.
12  // Let's do this the way a respectable MKS user would have wanted it.
13  std::cout << "Here's how right thinking people write "
14  << sft.reset().addF(av, 'e');
15 }
Format & reset()
reset the format string to its original value, with all the placeholders restored.
Definition: Format.cxx:207
int main()
Format & addF(double v, char fmt='f', unsigned int width=0, unsigned int frac_precision=3)
insert a float or double into the format string
Definition: Format.cxx:70
A format object that may be "filled in" with integer, float, double, string, or character values.
Definition: Format.hxx:269