SHARE
TWEET

Untitled

a guest Feb 26th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. using namespace std;
  3. struct krek{
  4.     char name [7];
  5.     int num;
  6. };
  7. void reading(int &n, krek A[])
  8. {
  9.     ifstream df ("data.txt");
  10.     df >> n;
  11.     for (int i = 0; i < n; i ++)
  12.     {
  13.         df.get(A[i].name, 7); df.ignore();
  14.         df >> A[i].num;
  15.         df.ignore();
  16.     }
  17.     df.close();
  18. }
  19. void writing(int n, krek A[])
  20. {
  21.     ofstream rf ("res.txt");
  22.     rf << n << endl;
  23.     for (int i = 0; i < n; i ++)
  24.     {
  25.         rf << A[i].name << " " << A[i].num << endl;
  26.     }
  27.     rf.close();
  28. }
  29. int main()
  30. {
  31.     krek A[10];
  32.     int n;
  33.     reading(n, A);
  34.     writing(n, A);
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top