Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main()
  5. {
  6. ifstream infile("in.txt");
  7. ofstream outfile("out.txt");
  8. bool done = false;
  9. int menu=3, item;
  10. while (!done)
  11. {
  12. cout << "1. Read from and write to file\n";
  13. cout << "2. Exit\n";
  14. cin >> menu;
  15. switch (menu)
  16. {
  17. case 1:
  18. while (infile >> item)
  19. {
  20. cout << item << endl;
  21. for (int i = 0; i < 5; i=i+2)
  22. {
  23. item++;
  24. cout << item << "\t";
  25. outfile << item << "\t";
  26. }//for
  27. cout << endl;
  28. outfile << endl;
  29. }//while
  30. infile.close();
  31. outfile.close();
  32. cout << "done.\n";
  33. break;
  34. case 2:
  35. done = true;
  36. break;
  37. default:
  38. break;
  39. }//switch
  40. }//while
  41.  
  42. return 0;
  43. }//main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement