Codes of the string

Can anybody help , my code for codes of the string is giving wrong answer : https://ide.geeksforgeeks.org/EAzg1VoVuj