yeah that's correct, thankyou
I've done this before. do you want it to take a specific line or just have it return the first and only?
This is the first version of my function. i have another that can return the line only if it starts with a specific substring
string getfile(string file, int line)
int j = 1;
string notfound = "line not found";
ifstream data( file.c_str() , ios::in);
while ( ! data.eof())
if (j == line )
or are you looking for a bool that just returns true if it is there?
I use a mixture of both, if you stick a "\n" in a file it will put the next bit of data on a newline. I think endl is just for console output. its probably good to get used to using "\n" as there are other escape sequences too, like \t (tab) \b (backspace) \" (double quotes) ect. :)