Unable to find the error

i am unable to find the error in this code

check updated code: https://ide.codingblocks.com/s/210502

the error was in substr() function , read about this function from cpp official site.

thanks