// CAT tool 
// By DreamVB 
#include <iostream> 
#include <stdio.h> 
using namespace std; 
using std::cout; 
using std::endl; 
int main(int argc, char* argv[]) 
{ 
	char c = '\0'; 
	int i = 1; 
	FILE* fp = NULL; 
	if (argc == 1) { 
		//Get input from con 
		while ((c = getc(stdin)) != EOF) { 
			//Save input to the console. 
			putc(c, stdout); 
		} 
	} 
	else 
		//Load files 
		while (i < argc) { 
			fp = fopen(argv[i], "rb"); 
			while ((c = getc(fp)) != EOF) { 
				//Check if at end of the file. 
				if (feof(fp)) { 
					break; 
				} 
				else { 
					//Prints to stdout 
					putc(c, stdout); 
				} 
			} 
			if (fclose(fp) != 0) { 
				cout << "IO/Error, Error closeing file " << argv[i]; 
				exit(1); 
			} 
			//INC counter 
			i++; 
		} 
	return 0; 
} 
