Skip to content

Instantly share code, notes, and snippets.

@haampie
Created September 20, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haampie/60ce71789316e87bcac8 to your computer and use it in GitHub Desktop.
Save haampie/60ce71789316e87bcac8 to your computer and use it in GitHub Desktop.
rereading stdin
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
string line;
bool foundStart = false;
size_t start = 0;
size_t end = 0;
for(size_t index = 0; getline(cin, line); ++index)
{
if(line != "")
{
end = index;
if(!foundStart)
{
foundStart = true;
start = index;
}
}
}
cout << start << " --- " << end << "\n";
cin.seekg(0, ios::beg);
for(size_t index = 0; getline(cin, line); ++index)
{
cout << "getting line\n";
if(index >= start && index <= end)
{
cout << line << "\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment