Problem in the code part related to stoi fuction

is it right to convert a int to a string and then convert fist character to int and then compare?
eg . i want to compare the first letter in in 2 int eg 90 and 234
and creat a function which has higher value of first dight so i tried this :
bool compare(int a, int b)
{int i=0;
string q=to_string(a);
string w=to_string(b);
while(q[i]!=NULL && w[i]!=NULL)
{int e=stoi(&q[i]);
int r=stoi(&w[i]);
if(e>r)
{return true;}
i++;
}
return false;
}
this is my compare part please tell what is wrong with this is giving error

@Eshika to_string(90) gives “90” and to_string(234) gives “234”
You can now simply compare a[0] and b[0].

If you want to compare the whole string lexicographically, you can compare it like a < b, directly.

I can help you more if you can elaborate on what exactly is the purpose of this function.

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.