seekg() won't allow you to choose a line. You could use getline() while(n != desired_line). A more efficient way would be to parse character by character and count the newlines, since you don't care for the strings getline() stores anyway:
1 2 3 4 5 6 7 8
std::ifstream ifs("file.txt");
char ch;
int n = 0; // lines are numbered from 0 here
while(n != desired_line && ifs.get(ch))
{
if(ch == '\n') ++n;
}
// now we can overwrite or read the file at desired_line
vector<string> filetext;
string mumblejumble("asdkjfhalskjdfhlaksjhfdlkasjdfhlkasjfhlksjdfhlaksjfhlksahf");
for (int i = 0; i < 1000; i++)
{
filetext.push_back(mumblejumble);
}
int lines_in_garbage = filetext.size();