Segmentation fault?

Tell me the mistakes ??..

#include<bits/stdc++.h>
using namespace std;
bool compare(pair<string,int> &a,pair<string,int> &b){
if(a.second>b.second){
return true;
}
else return false;
}
int main(){
int x;
cin>>x;
int n;
cin>>n;
vector<pair<string,int>> v;
for(int i=0;i<n;i++){
string s;
cin>>s;
int sal;
cin>>sal;
if(sal>=x){
v.push_back(make_pair(s,sal));
}
}
sort(v.begin(),v.end(),compare);
for(int i=0;v.size();i++){
cout<<v[i].first<<" "<<v[i].second<<endl;
}
}

@kundu4coding_ca066802126e25ef your code have 2 errors

  1. for segment error you are writing for(int i = 0; v.size(); i++) missing i<v.size()
  2. your comparator function do not compares the string only compares the values and then return false you have to compare the strings when the int values are same
    Coding Blocks IDE
    this is the corrected code
    if issue still exit let me know and if clear rate my experience

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.