From e9c5ab91e36e36e4d97b7310b89638f33b1e268a Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 4 Oct 2020 10:19:52 +0200 Subject: benutze die Argumente der Kommandozeile als Schlüssel... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/srcut.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/srcut.cpp') diff --git a/src/srcut.cpp b/src/srcut.cpp index 6df435b..0e5654a 100644 --- a/src/srcut.cpp +++ b/src/srcut.cpp @@ -83,26 +83,31 @@ operator>>(istream& in, map>& container) } ostream& -operator<<(ostream& os, const map>& container) +print(ostream& os, const string& key, const map>& container) { - for ( const auto& chunk: container ) { - os << "CHUNK: " << chunk.first << '\n'; - auto line = begin(chunk.second); - while ( line != end(chunk.second) ) { + const auto it = container.find(key); + if ( it != container.end() ) { + auto line = begin(it->second); + while ( line != end(it->second) ) { os << *line << '\n'; ++line; } - os << "-------\n\n"; + } + else { + os << "ERROR: " << key << " not found!" << endl; } return os; } int -main(void) +main(int argc, char* argv[]) { map> container; cin >> container; - cout << container; + + for ( int i = 1; i < argc; ++i ) { + print(cout, argv[i], container); + } } -- cgit v1.3