Advertisement
RobertDeMilo

WB4.6 Читаем данные через разделитель

Oct 11th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream input("C:/Users/musta/Downloads/text.txt");
  10.     string year;
  11.     string month;
  12.     string day;
  13.  
  14.     if (input)
  15.     {
  16.         getline(input, year, '-'); // читай до знака минус
  17.         getline(input, month, '-'); // читай до знака минус
  18.         getline(input, day, '-'); // читай до знака минус
  19.     }
  20.     cout << year << ' ' << month << ' ' << day;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement