All pastes #490944 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-05-16 10:33 UTC
rendered paste body
//Killeroid, blah blah#include <iostream>#include <fstream>using namespace std;const int size = 30;char filename[size];//char menu;bool isNotvalidate(int);void choose(int);char ext[4];char newname[size+5];void extension(int, char ext[]);void append(char filename[], char ext[], char newname[]);int main(){	int choice;	ifstream inputfile;	do	{		cout << "What file contains your data?  ";		cin >> filename;				cout << "1]  .txt " << endl;		cout << "2]  .dat " << endl;		cout << "3]  .in " << endl;		cout << "4]  .ttd " << endl;		cout << "What is the file extension?" << endl ;		cin >> choice;			}while(isNotvalidate(choice));	choose(choice);//SHows you the file extension you chose 	extension(choice, ext);	append(filename, ext, newname);	inputfile.open(newname);// open the file given		cin.ignore();	cin.ignore();	return 0;}bool isNotvalidate(int choice){	if(choice < 1 || choice > 4)		return true;	else		return false;}//char menu()//{//}void choose(int choice){	switch(choice)	{	case 1: cout << "Opening file " << filename << ".txt" << endl;		break;	case 2: cout << "Opening file " << filename << ".dat" << endl;		break;	case 3: cout << "Opening file " << filename << ".in" << endl;		break;	default: cout << "Opening file " << filename << ".ttd" << endl;		break;	}}void append(char filename[], char ext[], char newname[]){						for(int count=0; filename[count] != '\0'; count++)			newname[count] = filename[count];		for(int j=0; ext[j] != '\0'; j++)			newname[count] = ext[j];		newname[count] = '\0';}void extension(int choice, char ext[]){	if(choice == 1)		ext = '.txt';	else		if(choice == 2)			ext = '.dat';		else			if(choice == 3)				ext = '.in';			else				if(choice == 4)					ext = '.ttd';}