Как прочитать getline с переводом строки?
Как прочитать getline с переводом строки... а то приходится самому добавлять \n
.
#include <iostream>
#include <fstream>
#include <string>
void FuncReadFile(char* path, std::string &text)
{
//Переменная для чтения по указанному пути
std::ifstream FileInput(path);
std::string str;
while (!FileInput.eof())
{
getline(FileInput, str);
text = text+ str + "\n";
}
}
int main()
{
setlocale(LC_ALL, "RUS");
std::string text;
char* path = "input.txt";
FuncReadFile(path, text);
std::cout << text<<std::endl;
std::cout << "END" << std::endl;
system("pause");
}
Источник: Stack Overflow на русском