Question regarding file reading

A problem I'm doing is asking me to create a concordance with binary search trees. I've got it working and everything is done minus one part I can't seem to find info on. It's also asking me to count line numbers, which I would imagine is just keeping track of '\n' and incrementing the line number. A lot of the searches I'm coming up with are asking to ignore \n but I can't seem to find a post where people want to keep it. Maybe I'm asking the question wrong?
I'm currently using:

1
2
3
4
  while (File >> oneWord){
          //lowercase it
          //insert into BST 
       }

Is it possible to track the newlines with the way I've chosen to read in words? Or is getline the better option for this type of thing?
Thank you.
The >> skips newlines and other whitespace characters. The easiest way is probably to use std::getline as you said. Then you can use std::istringstream to read each word on each line.
Last edited on
Topic archived. No new replies allowed.