All pastes #794327 Raw Edit

hawg

public cpp v1 · immutable
#794327 ·published 2007-11-23 01:03 UTC
rendered paste body
#include <iostream>#include <fstream>#include <iomanip>#define SIZE 20using namespace std;struct CD {          char artist[48];          char album[48];          char reference[16];          float cost;          int year;};int main(){int option;int count = 0;bool exit = 0;          char art[48];          char alb[48];          char ref[16];          float cst;          int yr;char filename[100];struct CD catalog[SIZE];      while (!exit) {cout << "The following menu options are available:\n";cout << "Read in data [1]\n";cout << "Print out catalogue to screen [2]\n";cout << "Save data to file [3]\n";cout << "Exit program [4]\n";cout << "Enter your choice now:\n";cin >> option;if(option == 1)          {cout << "Please enter name of band/singer followed by ." << endl;cin.getline(art, 49, '.');strcpy ( catalog[count].artist, art );cout << "Please enter name of CD followed by ." << endl;cin.getline(alb, 48, '.');strcpy ( catalog[count].album, alb );cout << "Please enter reference followed by ." << endl;cin.getline(ref, 16, '.');strcpy ( catalog[count].reference, ref );cout << "Please enter cost:" << endl;cin >> cst;catalog[count].cost = cst;cout << "Please enter year of release:" << endl;cin >> yr;catalog[count].year = yr;count++;          }if(option == 2)          {for (int i=0; i<count; i++)    {    cout << "Record " << i << ":" << endl;    cout << "Artist: " << catalog[i].artist << endl;      cout << "Album Title: " << catalog[i].album << endl;      cout << "Reference: " << catalog[i].reference << endl;    cout << "Price: " << catalog[i].cost << endl;      cout << "Year: " << catalog[i].year << endl;      cout << endl;                  }            }if(option == 3)          {cout << "Please enter name of file to save to: ";cin >> setw(100) >> filename; ofstream fout(filename);for (int i=0; i<count; i++)    {    fout << "Record " << i << ":" << endl;    fout << "Artist: " << catalog[i].artist << endl;      fout << "Album Title: " << catalog[i].album << endl;      fout << "Reference: " << catalog[i].reference << endl;    fout << "Price: " << catalog[i].cost << endl;      fout << "Year: " << catalog[i].year << endl;      fout << endl;    }          }if(option == 4)          { exit = 1;          } exit;                    }}