SHARE
TWEET

Untitled

a guest Aug 12th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int AddArtifact(ofstream&, artifact[], int&, string); //Function prototype
  2.  
  3. AddArtifact(outData, Artlist,j, filename); //Function Call
  4.  
  5. //DEFINITION
  6.  
  7. int AddArtifact(ofstream& outData, artifact Artlist[], int& j, string filename)
  8. {
  9.  
  10.     j++;
  11.  
  12.     string nameA, monthA, firstA, lastA ;
  13.     int yearA = 0;
  14.  
  15.     cout << "Enter the artifact name: " << endl ;
  16.     cin >> nameA;
  17.     cout << "Enter the month: " << endl ;
  18.     cin >> monthA;
  19.     cout << "Enter the year: "  << endl ;
  20.     cin >> yearA;
  21.     cout << "Enter the first name: " << endl ;
  22.     cin >> firstA;
  23.     cout << "Enter the last name: " << endl ;
  24.     cin >> lastA;
  25. /*
  26.     cout << "Here's what you inputed: " << endl;
  27.     cout << nameA << endl;
  28.     cout << yearA << endl;
  29.     cout << monthA << endl;
  30.     cout << firstA << endl;
  31.     cout << lastA << endl;
  32. */
  33.     Artlist[j].name = nameA;
  34.     Artlist[j].month = monthA;
  35.     Artlist[j].year = yearA;
  36.     Artlist[j].First = firstA;
  37.     Artlist[j].Last = lastA;
  38. /*
  39.     cout << "Here's the new struct: " <<endl;
  40.     cout << Artlist[j].name << endl;
  41.     cout << Artlist[j].month << endl;
  42.     cout << Artlist[j].year << endl;
  43.     cout << Artlist[j].First << endl;
  44.     cout << Artlist[j].Last << endl;
  45. */
  46.     outData.open("artifacts.txt");
  47.  
  48.     outData << Artlist[j].name << endl;
  49.     outData << Artlist[j].month << endl;
  50.     outData << Artlist[j].year << endl;
  51.     outData << Artlist[j].First << endl;
  52.     outData << Artlist[j].Last << endl;
  53.  
  54.     outData.flush();
  55.     outData.close();
  56.  
  57.     return j;
  58.  
  59. }
RAW Paste Data
Top