1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <map>
using namespace std;
using std::cout;
using std::ifstream;
using std::string;
int main ()
{
srand (time(NULL)); //initialize the random seed
string userdatafile = ".udfile";
ifstream fin(userdatafile.c_str());
if(!fin) {
cout << "no userdata file present" << ".\n";
cout << "initialzing first time setup" << ".n";
string introinput;
int persChart = rand() % 8;
string chartArray[9] = {"lg", "ln", "le", "ng", "tn", "ne", "cg", "cn", "ce"};
ofstream outputfile(".udfile");
outputfile << chartArray[persChart] << endl;
outputfile.flush();
cout << "What's your name? ";
getline (cin, introinput);
outputfile << introinput << endl;
cout << "What is the month you were born? (Please enter in format: MM)";
getline (cin, introinput);
outputfile << introinput << endl;
cout << "What is the day you were born? (Please enter in format: DD)";
getline (cin, introinput);
outputfile << introinput << endl;
outputfile.close();
}
else {
}
ifstream infile;
string alignment, username, usermonth, userday,;
infile.open(".udfile");
getline(infile, alignment, \.n);
getline(infile, username, \.n);
getline(infile, usermonth, \.n);
getline(infile, userday, \.n);
cout << "my alignment is" << alignment <<endl;
cout << "hello " << username <<endl;
cout << " your entered month and day are " << usermonth << userday <<endl;
}
infile.close();
}
|