fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void myFunc(const char *strFloat) {
  8. cout << "myFunc: ";
  9. while(*strFloat) {
  10. cout << *(strFloat++);
  11. }
  12. cout << endl;
  13. }
  14.  
  15. int main() {
  16. const float var = 12.34;
  17. ostringstream ss;
  18. ss << std::fixed << setprecision(2) << var;
  19. myFunc(ss.str().c_str())
  20. return 0;
  21. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
myFunc: 12.34