Created
September 20, 2015 10:28
-
-
Save haampie/60ce71789316e87bcac8 to your computer and use it in GitHub Desktop.
rereading stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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