Advertisement
kej

Untitled

kej
Feb 19th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <fstream>
  4.  
  5. #include <cstring>
  6.  
  7. using namespace std;
  8.  
  9. struct Info
  10.  
  11. {
  12.  
  13. char surname[100];
  14.  
  15. char adress[100];
  16.  
  17. int cash;
  18.  
  19. int paid;
  20.  
  21. };
  22.  
  23. int main()
  24.  
  25. {
  26.  
  27. ifstream fin("input.txt");
  28. ofstream out_txt("paid.txt");
  29. ofstream out_bin("non-paid.bin", ios::binary);
  30.  
  31. Info b;
  32.  
  33. int k = 0; int n = 0;
  34.  
  35. int i;
  36.  
  37. if (!fin)
  38.  
  39. {
  40.  
  41. cout << "input.txt not found!" << endl;
  42.  
  43. system("pause");
  44.  
  45. exit(-1);
  46.  
  47. }
  48.  
  49. while (fin >> b.surname >> b.adress >> b.cash >> b.paid)
  50.  
  51. {
  52.  
  53. if (b.paid == 1)
  54.  
  55. {
  56. out_txt << b.surname << b.adress << b.cash;
  57. }
  58. else
  59. {
  60. out_bin << b.surname << b.adress << b.cash;
  61. }
  62.  
  63. }
  64.  
  65. fin.close();
  66. out_txt.close();
  67. out_bin.close();
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement