Try to adopt this improvisation:
const size_t allbut = std::numeric_limits<int>::max();
bool overStep(std::istream& in)
{
char c;
while (in.ignore(allbut,'S')) {
do
if (in.get(c) && c == 't' &&
in.get(c) && c == 'e' &&
in.get(c) && c == 'p' &&
in.get(c) && c == ' ' &&
in.get(c) && c == '[' &&
in.get(c) && c == '2' &&
in.get(c) && c == ']')
return true;
while (in && c == 'S');
}
return false;
}
// mini-test
int main()
{
std::ifstream fin("step.txt");
std::string after;
while (overStep(fin)) {
if (fin >> after)
std::cout << after << '\n';
}
return 0;
}
Last edited by ArkM; Jun 15th, 2009 at 6:37 pm.
Reputation Points: 1234
Solved Threads: 347
Postaholic
Offline 2,001 posts
since Jul 2008