beginning question

I don't know much C++. I did mostly java but I'm trying to write a program in C++. The idea is simple, it looks at a text file and makes a new textfile from some data in the original. That part works fine. Now I need to break up each line of this new textfile into individual parts. In java I'd use substring to do this but in C++ it doesn't quite work the way I want. I'm trying to print a name on the line. The name always starts 6 characters in, and is terminated by the first occurence of "</td>". It doesn't do what I want it and prints random amounts of characters. Here's what I have:

You should check the return value of find against string::npos to make sure it found something. Also, find_first_of finds the first character in that string. You probably want find.

On a separate note, you should probably replace the is_open call in the while control with the call to getline. You want to check the return value of getline before you use the string it gets. It will evaluate to false if it failed to get any data. Just check is_open separately before the loop.

Well, it works now. I didn't really understand alot of what you guys said but I did use find instead of find_first. I'm still not sure what substring is doing right now but its working. betweenNames has a </td> in it and it finds the first occurrence and returns the index at the end of it, so I have to substract the length of </td> - 1, and it seems to get the text from 6 to there.