From 7c9146efca9b565777e1093e65272f710ae5d0d9 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 9 Oct 2016 12:56:59 +0300 Subject: Add editor content outputting --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 1389efd..6378f1e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,19 +1,19 @@ #include #include #include +#include #include "editor.h" -std::string* read_file(const std::string& filename) { +std::vector* read_file(const std::string& filename) { std::ifstream file(filename); if (file.fail()) return nullptr; std::string str; - std::string* file_contents = new std::string(); + std::vector* file_contents = new std::vector(); while (std::getline(file, str)) { - *file_contents += str; - file_contents->push_back('\n'); + file_contents->push_back(str); } return file_contents; @@ -26,7 +26,7 @@ int main(int argc, char** argv) { } std::string filepath(argv[1]); - std::string* contents = read_file(filepath); + std::vector* contents = read_file(filepath); if (contents == nullptr) { std::cout << "Error reading file.\n"; return 1; -- cgit v1.3