Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5.  
  6. struct movies_t {
  7. string title;
  8. int year;
  9. } mine, yours;
  10.  
  11. void printmovie (movies_t movie);
  12.  
  13. int main ()
  14. {
  15. string mystr;
  16.  
  17. mine.title = "2001 A Space Odyssey";
  18. mine.year = 1968;
  19.  
  20. cout << "Enter title: ";
  21. getline (cin,yours.title);
  22. cout << "Enter year: ";
  23. getline (cin,mystr);
  24. stringstream(mystr) >> yours.year;
  25.  
  26. cout << "My favorite movie is:\n ";
  27. printmovie (mine);
  28. cout << "And yours is:\n ";
  29. printmovie (yours);
  30. return 0;
  31. }
  32.  
  33. void printmovie (movies_t movie)
  34. {
  35. cout << movie.title;
  36. cout << " (" << movie.year << ")\n";
  37. }
Add Comment
Please, Sign In to add comment