Segmentation fault


In the above code,i am trying to design a function which compares two variables in the sense that which number is having the highest Most significant place.For example 6 >50 because the most significant digit of 6 is 6 and of 50 is 5 so 5 is greater.In the same way 506 >504 because the earlier two most significant digits are same so we will compare 6 and 4 which results in 506 as an answer.
But while coding it,i am getting segmentation fault.Please help

if you want to do this it is better to keep the numbers in string format since what you are trying to do is the definition of lexicographic-ally sorting
Code for reference purpose