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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#include "main.h"
using namespace std;
void GetVendor (booth *booth_ptr);
void GetCategory (booth *booth_ptr);
int main()
{
ifstream fin;
ofstream fout;
char again('Y');
booth booth_dat;
booth *structPointer = new booth[3];
while (again == 'Y' || again == 'y')
{
GetVendor ( &booth_dat );
GetCategory ( &booth_dat );
cout << "Would you like to run again?(y/n) " << endl;
cin >> again;
cin.ignore(100, '\n');
}
return 0;
}
void GetVendor (booth *booth_ptr)
{
ofstream myfile;
char temp[100];
myfile.open("booth.txt", ios::app);
char again('Y');
int i(0);
if (myfile.is_open())
{
while (again == 'y' || again == 'Y' && i < 20)
{
cout << "Please enter Vendor name: " << endl;
cin.getline (temp, 100);
cin.ignore(100, '\n');
booth_ptr->vendorName = new char[strlen(temp) + 1];
strcpy( booth_ptr->vendorName, temp);
myfile << booth_ptr->vendorName;
myfile.close();
i++;
cout << "Would you like to enter another vendor?(y/n): " << endl;
cin >> again;
}
void GetCategory ( booth *booth_ptr )
{
int i(0);
ofstream myfile;
char temp[100];
char again('Y');
myfile.open ("booth.txt", ios::app);
if (myfile.is_open())
{
while (again == 'y' || again == 'Y' && i < 20)
{
cout << "please enter the catagory of your booth: " << endl;
cin.getline(temp, 100);
cin.ignore(100, '\n');
booth_ptr->category = new char[strlen (temp) + 1];
strcpy ( booth_ptr->category, temp);
myfile << booth_ptr->category;
myfile.close();
i++;
cout << "Would you like to enter another vendor?(y/n): " << endl;
cin >> again;
}
void GetDescription ( booth *booth_ptr )
{
int i(0);
ofstream myfile;
char temp[1000];
char again('Y');
myfile.open ("booth.txt", ios::app);
if (myfile.is_open())
{
while (again == 'y' || again == 'Y' && i < 20)
{
cout << "Please provide a description for your booth: " << endl;
cin.getline(temp, 1000);
cin.ignore(1000, '/n');
booth_ptr -> description = new char[strlen (temp) + 1];
strcpy ( booth_ptr -> description, temp);
myfile << booth_ptr -> description;
myfile.close();
i++;
cout << "Would you like to enter another vendor?(y/n): " << endl;
cin >> again;
}
}
}
}
|