I am trying to parse a large text file and store the words in a vector for processing later on.
The file contains words, digits, and special chars.
I think I am stuck with splitting the line and also the output file is just empty. Showing nothing.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
usingnamespace std;
constchar* const DELIMITER = " ";
int main()
{
vector<string> words;
string line;
ifstream input_file;
input_file.open("1flp.pdb");
ofstream output_file ("out.txt");
// if the file does not exist, return 1
if (!input_file.good()) { return 1; }
// read until the end of the file
while (!input_file.eof()) {
// read an entire line into memory and store in line
getline(input_file, line);
if(output_file.is_open()) {
output_file << line;
}
}
input_file.close();
output_file.close();
return 0;
}