#include <iostream>
#include <fstream>
#include <vector>
int main()
{
std::wfstream file("../Data/books.txt", std::wios::in);
std::vector<std::wstring> lines;
std::wstring line;
while (!file.eof())
{
std::getline(file, line);
lines.push_back(line);
}
for (const auto& item : lines)
std::wcout << item << std::endl;
return 0;
}
Using that code, I am aiming to read all of the lines from a file and store them in a std::vector
.
File has the following content:
Bir Ömür Nasıl Yaşanır
İlber Ortaylı
1
1
1
But when I print the elements of the vector, the only output shown is Bir
.
The way for reading from file to std::string
is basically this, is it different for std::wstring
? If so, how can I do it with std::wstring
?