SIGSEGV error in JNEXT of spoj

The link to my code of JNEXT of spoj is http://ideone.com/GvvvrN
And I have followed the steps given in http://stackoverflow.com/questions/1622532/algorithm-to-find-next-greater-permutation-of-a-given-string/1622539#1622539 . But still this solution is giving me run time error.
Please help me out.And thanks in advance.