aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-10-09 12:56:59 +0300
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-10-09 14:50:24 +0300
commit7c9146efca9b565777e1093e65272f710ae5d0d9 (patch)
tree7077241a78ee1f8d9a7044b08eb4714ad47f4020 /main.cpp
parent88996781bd89825501ae18a1ce6e7744e767db86 (diff)
Add editor content outputting
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/main.cpp b/main.cpp
index 1389efd..6378f1e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,19 +1,19 @@
#include <iostream>
#include <fstream>
#include <string>
+#include <vector>
#include "editor.h"
-std::string* read_file(const std::string& filename) {
+std::vector<std::string>* 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<std::string>* file_contents = new std::vector<std::string>();
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<std::string>* contents = read_file(filepath);
if (contents == nullptr) {
std::cout << "Error reading file.\n";
return 1;