Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <codecvt>
- #include <string>
- #include <sstream>
- #include <fstream>
- #include <codecvt>
- //std::locale::global(std::locale(std::locale, new std::codecvt_utf8<wchar_t>));
- std::wstring readFile(const char* filename)
- {
- std::wifstream wif(filename);
- wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t,0x10ffff, std::consume_header>));
- std::wstringstream wss;
- wss << wif.rdbuf();
- return wss.str();
- }
- using namespace std;
- int main() {
- setlocale(LC_ALL, "rus");
- // wifstream fin("stroka_3.txt");
- // wstring A[20];
- wstring a = readFile("stroka_3.txt");
- wcout << a << endl;
- // cout << "Построчный вывод из файла:" << endl;
- // for (int i = 0; i < n; i++) {
- //
- // wcout << "Строка " << i << " -> " << A[i] << endl;
- // cout << '\t' << "Количество символов = " << A[i].size() << endl;
- //
- // int count = 1;
- // for (int j = 0; j < A[i].size() - 1; j++)
- // if (A[i][j] == ' ' && A[i][j + 1] != ' ')
- // count++;
- //
- // cout << '\t' << "Количество слов = " << count << endl;
- // }
- // cout << "Всего строк -> " << n << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment