fork(3) download
  1. #include <iostream>
  2.  
  3. int main(void) {
  4. std::streamsize ss = std::cout.precision();
  5.  
  6. double a = 1.267432;
  7.  
  8. std::cout << "a = " << a << '\n';
  9.  
  10. std::cout.precision(3);
  11. std::cout << "a becomes = " << a << '\n';
  12.  
  13. // std::cout.precision(ss);
  14. // std::cout << "Original a= " << a << '\n';
  15.  
  16. std::cout << "The number a in fixed: " << std::fixed(6) << ss << '\n'
  17. << "The number a in default: " << std::defaultfloat << a << '\n';
  18.  
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 3460KB
stdin
1.267432
compilation info
prog.cpp: In function 'int main()':
prog.cpp:16:61: error: invalid initialization of non-const reference of type 'std::ios_base&' from an rvalue of type 'int'
  std::cout << "The number a in fixed:      " << std::fixed(6) << ss << '\n'
                                                             ^
In file included from /usr/include/c++/5/ios:42:0,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/ios_base.h:1035:3: note: in passing argument 1 of 'std::ios_base& std::fixed(std::ios_base&)'
   fixed(ios_base& __base)
   ^
stdout
Standard output is empty