Modernes C++ programmieren

Okt 23, 2024

lst-0212-book.cpp

void process(const vector<string>& args) {
    if(args.size() == 0) {                 // erwarte Parameter
        throw std::invalid_argument{"Kommandozeilenargument fehlt"};
    } else {
        for(const string filename : args) {
            cout << filename << ": ";
            try {
                cout << zaehleWoerter(filename) << "\n";
            } catch(std::exception &exc) {
                cout << "Fehler: " << exc.what() << "\n";
            }
        }
    }
}