All pastes #43258 Raw Edit

lotus_anima

public cpp v1 · immutable
#43258 ·published 2006-02-26 21:19 UTC
rendered paste body
#include <iostream>#include <fstream>#include <cstdlib>#include <string>using namespace std;int main(){//	ifstream inStream("infile1.txt");	string line, inFile;	unsigned short int x = 1;	cout << "Please enter the name of the file you'd like to open: ";	cin >> inFile; cout << endl;	ifstream inStream(inFile);	if( !inStream.is_open() ){		cerr << "Failed to open " << "file" << " for reading." << endl;		exit(1);	} else{		while(getline(inStream, line) && !inStream.eof() ){			cout << x << ": " << line << endl;			x++;		}		inStream.close();	}	return 0;}