// pointers to structures #include <iostream> #include <string> #include <sstream> using namespace std; struct movies_t { string title; int year; }; int main () { string mystr; movies_t amovie; movies_t * pmovie; pmovie = &amovie; cout << "Enter title: "; getline (cin, pmovie->title); cout << "Enter year: "; getline (cin, mystr); (stringstream) mystr >> pmovie->year; cout << " You have entered: "; cout << pmovie->title; cout << " (" << pmovie->year << ") "; return 0; }
line 17 taking a line input to the instance variable amovie->title by conjunction with getline() and cin core object
Comments 5