C++ read from file, skipping some information -


i need way of reading following file:

this line not needed line not needed name   telephone john   0000001 mark   0000002 . . . 

i want skip first lines, , thrid line headers. want save names in string variable , telephone in string variable. there tabs between data.

so code won't work.

string line;  while (getline(infile, line))  {   istringstream iss(line);   int a, b;    if (!(iss >> >> b))    { break; } // error     // process pair (a,b)  } 

so know how skip information header , parse information in variables. cheers.

how keep reading file start storing string after have read telephone!

something this:

string str, newstr; boolean = false; while(cin >> str){     if(str.compare("telephone")== 0)         boolean = true;     if(boolean)         newstr += str; } return newstr; 

make sure include string compare method


Comments