Hi again, I ran to some problems in input some codes but i'm quite sure that my code is correct but the output is not what I expect it to be, this is my code:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
struct movie{
string title;
int year;
};
struct info{
string name;
movie fmovie;
};
void main(){
info xinfo;
cout<<"Enter name: ";
getline(cin, xinfo.name);
cout<<"Enter movie: ";
getline(cin, xinfo.fmovie.title);
cout<<"Enter year: ";
cin>>xinfo.fmovie.year;
cout<<"Name is "<<xinfo.name<<endl;
cout<<"Movie is "<<xinfo.fmovie.title<<endl;
cout<<"Year is "<<xinfo.fmovie.year<<endl;
}
When I run this, it asks for the name but when I type in my name and press enter it doesn't proceed to asking for the movie, it just hangs there in the newline doing nothing, so I press enter again, and it asks for the movie now, i press enter and its asks for the year now, but then in the final out only name is shown and the other two is fucked up..why is this?
output looks like this:
Enter name: john
Enter movie: avatar
Enter year:
Name is john
Movie is
Year is -85999284