Running the same code on vs but doest work

#include
#include
#include
using namespace std;

string extractstringkey(string str, int key){
char *s = strtok((char )str.c_str(), " ");
while (key>1)
{
/
code */
s=strtok(NULL," ");
key–;
}
return (string)s;

int convertToInt(string s){
int ans = 0;
int p = 1;
for (int i = s.length()-1; i>=0; i–)
{
ans+= ((s[i]-‘0’)p);
p=p
10;
}
return ans;

}

bool numericCompare(pair<string , string>s1, pair<string , string>s2){
string key1,key2;
key1 = s1.second;
key2 = s2.second;
return key1 < key2;
}
bool lexicoCompare(pair<string , string>s1, pair<string , string>s2){
string key1,key2;
key1 = s1.second;
key2 = s2.second;
return convertToInt(key1) < convertToInt(key2);
}

}
int main(){
int n;
cin>>n;
cin.get();
string a[100];
for(int i=0;i<n;i++){
getline(cin,a[i]);
}

int key;

string reversal, ordering;

cin>>key>>reversal>>ordering;

pair<string,string> strPair[100];

for ( int i=0;i<n;i++){
    strPair->first = a[i];
    strPair->second = extractstringkey(a[i],key);
}
if(ordering == "numeric"){
    sort(strPair, strPair+n,numericCompare)
}
else{
    sort(strPair, strPair+n,lexicoCompare);

}
if(reversal=="true"){
    for(int i=0;i<n/2;i++ ){
        swap(strPair[i],strPair[n-i-1]);
    }
}

for (int i=0;i<n;i++){
    cout<<strPair[i].first<<" ";
}

return 0;

}
errors are: eq_spacedstring_comparison.cpp: In function ‘std::string extractstringkey(std::string, int)’:
eq_spacedstring_comparison.cpp:16:27: error: a function-definition is not allowed here before ‘{’ token
16 | int convertToInt(string s){
| ^
eq_spacedstring_comparison.cpp:28:70: error: a function-definition is not allowed here before ‘{’ token
28 | bool numericCompare(pair<string , string>s1, pair<string , string>s2){
| ^
eq_spacedstring_comparison.cpp:34:69: error: a function-definition is not allowed here before ‘{’ token
34 | bool lexicoCompare(pair<string , string>s1, pair<string , string>s2){
| ^
eq_spacedstring_comparison.cpp: In function ‘int main()’:
eq_spacedstring_comparison.cpp:64:34: error: ‘numericCompare’ was not declared in this scope
64 | sort(strPair, strPair+n, numericCompare)
| ^~~~~~~~~~~~~~
eq_spacedstring_comparison.cpp:67:34: error: ‘lexicoCompare’ was not declared in this scope
67 | sort(strPair, strPair+n, lexicoCompare);
| ^~~~~~~~~~~~~

@kk06112001 please share code using cb ide

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.