#include <iostream> #include <fstream> #include <functional> void write(const char* filename) { std::ifstream file(filename); if(file.good()) { std::cout << file.rdbuf(); } else { std::cout << "CANNOT OPEN " << filename << '\n'; } } int main(int argc, char* argv[]) { if(argc == 1) { std::cout << std::cin.rdbuf(); } else { std::for_each(argv + 1, argv + argc, std::ptr_fun(write)); } return 0; }