fork(1) download
  1. #include <iostream>
  2. #include <ostream>
  3. #include <istream>
  4. #include <ostream>
  5. #include <fstream>
  6. #include <sstream>
  7. #include <string>
  8. #include <iomanip>
  9.  
  10. int main()
  11. {
  12.  
  13. double newTotalPrice = 33333;
  14. double newTotalMileage = 44444;
  15. double usedTotalPrice = 22222;
  16. double usedTotalMileage = 99999;
  17. int numUsed = 2;
  18. int numNew = 3;
  19. std::ofstream fout; // 'f'ile out - fout
  20. std::string filename = "statistics.txt";
  21. GetOutputFileStream(&fout, filename);
  22. // Print to screen
  23. PrintStatistics(std::cout,
  24. numUsed,
  25. numNew,
  26. newTotalPrice,
  27. newTotalMileage,
  28. usedTotalPrice,
  29. usedTotalMileage);
  30. // Print to file
  31. PrintStatistics(fout,
  32. numUsed,
  33. numNew,
  34. newTotalPrice,
  35. newTotalMileage,
  36. usedTotalPrice,
  37. usedTotalMileage);
  38.  
  39.  
  40. std::cout << "Press ENTER to continue";
  41. std::cin.get();
  42.  
  43. return 0;
  44. }
  45.  
  46. void GetOutputFileStream(std::ofstream * fout, std::string filename)
  47. {
  48. fout->open(filename, std::ios::out);
  49. }
  50. void PrintStatistics(std::ostream & fout,
  51. int numUsed,
  52. int numNew,
  53. double newTotalPrice,
  54. double newTotalMileage,
  55. double usedTotalPrice,
  56. double usedTotalMileage)
  57. {
  58.  
  59. }
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:21:36: error: 'GetOutputFileStream' was not declared in this scope
 GetOutputFileStream(&fout, filename);
                                    ^
prog.cpp:29:21: error: 'PrintStatistics' was not declared in this scope
     usedTotalMileage);
                     ^
stdout
Standard output is empty