Raslboyy

Untitled

May 29th, 2021
1,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <codecvt>
  4. #include <string>
  5. #include <sstream>
  6. #include <fstream>
  7. #include <codecvt>
  8.  
  9. //std::locale::global(std::locale(std::locale, new std::codecvt_utf8<wchar_t>));
  10.  
  11. std::wstring readFile(const char* filename)
  12. {
  13.   std::wifstream wif(filename);
  14.   wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t,0x10ffff, std::consume_header>));
  15.   std::wstringstream wss;
  16.   wss << wif.rdbuf();
  17.   return wss.str();
  18. }
  19.  
  20. using namespace std;
  21.  
  22. int main() {
  23.  
  24.   setlocale(LC_ALL, "rus");
  25.  
  26. //  wifstream fin("stroka_3.txt");
  27. //  wstring A[20];
  28.  
  29.   wstring a = readFile("stroka_3.txt");
  30.   wcout << a << endl;
  31.  
  32.  
  33.  
  34. //  cout << "Построчный вывод из файла:" << endl;
  35. //  for (int i = 0; i < n; i++) {
  36. //
  37. //    wcout << "Строка " << i << " -> " << A[i] << endl;
  38. //    cout << '\t' << "Количество символов = " << A[i].size() << endl;
  39. //
  40. //    int count = 1;
  41. //    for (int j = 0; j < A[i].size() - 1; j++)
  42. //      if (A[i][j] == ' ' && A[i][j + 1] != ' ')
  43. //        count++;
  44. //
  45. //    cout << '\t' << "Количество слов = " << count << endl;
  46. //  }
  47. //  cout << "Всего строк -> " << n << endl;
  48.  
  49.   return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment