parsing a text file and storing the words in a vector

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

const char* 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;
}

Last edited on
Topic archived. No new replies allowed.