file input problem

So I found a way to just input my file and just see what happens if I just read it in and print it back out using this:

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

using namespace std;
int main(){
ifstream file("TableOfContentProjectInput.dat");
string line;
while(getline(file, line))
cout << line << '\n';

but as I am reading in an input like what I am going to post below (the actual file is much much larger than the sample i provided) It just outputs the lines starting with p like all of the paragraphs and the prtb part. Why doesn't it read in and then output exactly what was read in? Is it an issue with the input file being so irregular? I can't even go about turning this input into a table of contents without figuring out this issue of input first.

chap ` the tragedy of` 0
chap `hamlet prince of denmark by william` 0
chap `shakespeare dramatis personae claudius king` 0
chap `of denmark marcellus officer hamlet son` 1
sec `to the former and nephew` 1 0
chap `to the present king` 1
sub `polonius lord chamberlain horatio friend` 1 1 0
sec `to hamlet laertes son to polonius` 4 0
par 1 1 1 1 0
sec `voltemand courtier cornelius courtier rosencrantz` 2 0
sec `courtier guildenstern courtier osric courtier a` 4 1
sec `gentleman courtier a priest` 5 0
par 4 1 1 1 1
sub `marcellus officer bernardo officer francisco a` 1 1 1
chap `soldier reynaldo servant to polonius` 2

Edit: oh wait never mind I just cant see high enough in the cmd window that comes up to see the other stuff. New question though. After reading in the file correctly then how do you start taking each line specifically and put it into a linked list or a bst to sort it since the input is so strange?
Last edited on
Topic archived. No new replies allowed.