All pastes #103990 Raw Edit

Stuff

public cpp v1 · immutable
#103990 ·published 2006-07-28 15:20 UTC
rendered paste body
#include <iostream>#include <string>#include <fstream>using namespace std;int readfile(void);int printNames(void);int main(int argc, char *argv[]){int choice = 0;bool numExit = false;while (numExit != true){	cout << "1. Read File" << endl << "2. Hello World!" << endl <<"3. Print Commandline Argument "<< endl << "4. End Program" <<endl;	cin>>choice;	switch (choice)	{	case 1:		readfile();		break;	case 2:		cout<< "Hello World! "<<endl;		break;		case 3:		if (argc < 2)		{			cout<< "Error not enough arguments" <<endl;		}		else		{			cout<< "Hello " << argv[1] <<endl;		}		break;	case 4:		numExit = true;		break;	default:		break;	}				} }int readfile(void){		ifstream fin;		string name = "";		fin.open ("helloworld.txt");		if (fin.fail())		{			cout<<"Error could not open file!" <<endl;		}		getline(fin, name);		if (name == "")		{			cout<< "Hello World!"<<endl;		}		else 		{			while(fin >> name)			{				cout<< "Hello " << name << "!" << endl;			}		}		fin.close();		return 0;}