Does cin or getline make a difference while using pair

this code works as it is but if I replace the cin>>name in main funtion with getline(cin,name) it gives zero as answer for all values in vector v.

#include<bits/stdc++.h>

using namespace std;
bool compare(pair<string,int> a,pair<string,int> b)
{
if(a.second==b.second)
{
return a.first<b.first;
}
return a.second>b.second;
}
int main()
{
int num;
cin>>num;
int n;
cin>>n;
vector<pair<string,int> > v;
for(int i=0;i<n;i++)
{
int salary;
string name;
//problem
cin>>name;
cin>>salary;
v.push_back(make_pair(name,salary));
}
sort(v.begin(),v.end(),compare);
for(auto x:v)
{
int d1=x.second;
if(d1>=num)
cout<<x.first<<" "<<x.second<<endl;
}
return 0;
}

@praritv1 hey,cin can take input of string without spaces whereas getli e is use to take input for strings separated with spaces .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.