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
|
"#include <iostream>
#include <cctype>
#include <string.h>
#include <stdio.h>
#include <fstream>
#include <string>
using namespace std;
int main(){
int ans;
char keyword[10];
int s;
char search[100];
struct events{
char name[100];
char location[100],
description[100],
date[100],
attendance[100],
enthusiasm[100];
};
events activity[50];
ofstream indata;
ifstream input;
indata.open("summer-list.txt");
input.open("summer-list.txt");
do{
for( s =0; s < 5; s++){
cout << "Enter the event name: ";
cin >> activity[s].name;
cin.ignore(100, '\n');
indata << activity[s].name << " # ";
cout << "Enter the event loaction: ";
cin>> activity[s].location;
cin.ignore(100, '\n');
indata << activity[s].location << " # ";
cout << "Enter the event date: ";
cin>> activity[s].date;
cin.ignore(100, '\n');
indata << activity[s].date << " # ";
cout << "Enter the event attendance: ";
cin>> activity[s].attendance;
cin.ignore(100, '\n');
indata << activity[s].attendance << " # ";
cout << "Enter the event enthusiasm: ";
cin>> activity[s].enthusiasm;
cin.ignore(100, '\n');
indata << activity[s].enthusiasm << " # " << '\n';
cout << "Would you like to enter another event(1) or search for an event with a keyword(2) or print(3)" << endl;
cin >> ans;
cin.ignore(100, '\n');
if (ans == 2 || ans == 3){
break;
}
}
}while(ans == 1);
if(ans ==2){
cout << "Enter a keyword: " << endl;
cin >> keyword;
cin.ignore(100, '\n');
//int length = strlen(activity[50].name);
//for(int m=0; m< length; m++){
// while(strcmp(keyword, activity[m].name )==0)
while(!input.eof()){
input.get(search, 100, '\n');
if(search.find(string) != string::npos){
cout << search;
}
}
}
if (ans == 3) {
cout<< "Name # Location # Date # Attendance # Enthusiasm " << endl;
for(s =0; s< 5; s++){
cout << activity[s].name << " # " << activity[s].location <<
" # " << activity[s].date << " # " << activity[s].attendance << " # " << activity[s].enthusiasm << endl;
}
}
indata.close();
}
|