Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct Record
- {
- string title;
- string artist;
- int year;
- };
- void displayRecord(const Record &r)
- {
- cout << r.title << " - " << r.artist << " (" << r.year << ")"<< endl;
- }
- int main()
- {
- int recordamount;
- Record records[recordamount];
- cout << "How many records do you wish to input? (Between 0 and 100)" << endl;
- cin >> recordamount;
- if (recordamount > 0 && recordamount < 100)
- {
- for (int i = 0; i < recordamount; i++)
- {
- cout << "Enter the title of the record:";
- getline(cin, records[i].title);
- cout << "Enter the artist of the record:";
- getline(cin, records[i].artist);
- cout << "Enter the year of the record:";
- getline(cin, records[i].year);
- }
- for (int i = 0; i < recordamount; i++)
- {
- displayRecord(records[i]);
- cout << endl;
- }
- }
- else
- {
- cout << "You did not enter a valid number." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement