Skip to content

Instantly share code, notes, and snippets.

@haampie
Created Sep 20, 2015
Embed
What would you like to do?
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