How to take integer after gets()

I am trying to solve a problem , in that i have to take a string input until enter is pressed and then a integer . I am using this code but its taking integer value as 0 everytime
int n;
char s[500];
cout<<s<<" "<<n<<endl;

input : Hello world
output : Hello world 0

Actually i am not even able to give the integer input , it take itself as 0 .

If possible, try using this instead of char and gets

string s;
getline(cin, s);

I tried it , but this didnt worked. Its the same result :frowning_face:

Can you share the question??

It was a interview question . I dont remember it properly but it was easy . I was not even able to take the input :frowning_face:.