How to read text file (.txt) into vector of char using STL

I have file text.txt and want to change upper case letters to lower case letters.
I'm not sure how to read from the file and use STL list<char> to store letters.
http://www.cplusplus.com/reference/iostream/ifstream/
Just get() each character from the file and add it to the list. ;)
Now I can store characters in <list>.
I want to replace 'ph' with 'f' in words.
For example, the word "photograph" becomes "fotograph".
Can I do this with iterator?
Why are you using a vector for this? Why don't you use a string?????
My project requires me to use vector. I can't use anything else.
closed account (D80DSL3A)
Can I do this with iterator?

Just picture how to do it and then write the code:
1) Use the iterator to search for 'p'.
2) When a 'p' is found check if next element == 'h'
3) If so, overwrite 'p' with 'f' and remove the next element.
Untested, but it seems like that would work.
Yeah, but can we access to prev and next pointers of nodes in list?
closed account (D80DSL3A)
The iterator for a list is bi-directional so ++iter gives next and --iter gives prev. (hence the term "iterator").
Please read up so you know how to use a list.
http://www.cplusplus.com/reference/stl/list/
Have some code showing an attempt for further help.
Last edited on
Thanks you guys. Finally, I can do it. :D
Topic archived. No new replies allowed.