Accelerated C++ Exercise 10-0

#include <iostream>
#include <string>
#include <fstream>

using std::cout;
using std::ios;
using std::ifstream;
using std::string;
using std::getline;
using std::endl;
using std::cerr;

int main(int argc,char** argv)
{
	int fail_count=0;
	for(int i=1;i<argc;++i){
		ifstream in(argv[i]);
		if(in){
			string s;
			while(getline(in,s)){
				cout<<s<<endl;
			}
		}
		else{
			cerr<<"Connot open file "<<argv[i]<<endl;
			++fail_count;
		}
	}
	return fail_count;
}


		

你可能感兴趣的:(Accelerated C++ Exercise 10-0)