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
|
#include <iostream>
#include <fstream>
using namespace std;
#include <cstring>
#include <cctype>
const int game_name = 35;
const int rating_of_game = 6;
const int platform = 30;
const int comments = 250;
const int summary = 400;
const int email = 35;
struct game_info
{
char name_of_game[game_name];
char game_rating[rating_of_game];
char game_platform[platform];
char game_comments[comments];
char summary_of_game[summary];
char email_address[email];
bool availability;
};
//prototypes
void readall(char prompt[], int max_size, char result[]);
void getting_game_info(*pointer);
char display(game_info & game, int i);
int main(){
char filename[32]; // array to hold filename
int num_games = 0; //array to hold number of games
game_info * pointer= new game_info[20]; //array of my struct
//game_info single_game; //setting up variable for a single game
char character; //character to set my loop up
int i =0;
getting_game_info(pointer); //calling function
display(single_game, i);
}
void readall(const char prompt[], int max_size, char result[])
{
cout <<prompt << '\n';
cin.get(result, max_size, '\n');
cin.ignore(100, '\n');
}
void getting_game_info(*pointer)
{
char character;
do {
readall("please enter name of game", game_name, pointer[i].name_of_game);
readall("please enter the rating of the game", rating_of_game, pointer[i].game_rating);
readall("please enter the game platform", platform, pointer[i].game_platform);
readall("please enter your comments about the game", comments, pointer[i].game_comments);
readall("please enter your summary of the game", summary, pointer[i].summary_of_game);
readall("please enter your email address", email, pointer[i].email_address);
cout <<"Is this information correct? Enter either y or n." << '\n';
cin >>character;
cin.ignore();
cout <<'\n';
} while((character == 'n') || (character == 'N'));
}
char display(game_info & game, int i)
{
//for(int j=0;j=i;++j)
//{
cout <<"The name of the game is: "<<game[0].name_of_game << endl;
cout << "The rating of the game is: "<<game[0].game_rating <<endl;
cout <<"The game platform is: "<<game[0].game_platform <<endl;
cout << "The game comments are: "<<game[0].game_comments <<endl;
cout << "Summary of the game: "<<game[0].summary_of_game <<endl;
cout << "Persons email address: "<<game[0].email_address <<endl;
//}
}
|