Structure initialization with the Movie collection. - C++ Data Type

C++ examples for Data Type:struct

Description

Structure initialization with the Movie collection.

Demo Code

#include <iostream>
using namespace std;
#include <string.h>
void main()//from w ww  .  j ava  2  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 << "Title: " << 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;
}

Result


Related Tutorials