Move all x's at the end of string

My code is not passing all the test cases, can someone please explain the reason for it and help me correct my code.
Link to My code: (https://ide.codingblocks.com/s/633533))