C++ struct Structure initialization with the Movie collection

Description

C++ struct Structure initialization with the Movie collection

#include <iostream>
using namespace std;
#include <string.h>
void main()//www  .j a va2  s.co  m
{
   struct Movie
   {
      char title[25];
      char artist[20];
      int num_songs;
      float price;
      char date_purch[9];
   } cd1;
   // Initialize members here.
   strcpy(cd1.title, "R");
   strcpy(cd1.artist, "S");
   cd1.num_songs=12;
   cd1.price=11.95;
   strcpy(cd1.date_purch, "02/13/92");
   // Print the data to the screen.
   cout << "Here is the CD information:\n\n";
   cout << "name  " << cd1.title << "\n";
   cout << "Artist: " << cd1.artist << "\n";
   cout << "Songs: " << cd1.num_songs << "\n";
   cout << "Price: " << cd1.price << "\n";
   cout << "Date purchased: " << cd1.date_purch << "\n";
   return;
}



PreviousNext

Related