Code is giving an error

code:https://ide.codingblocks.com/s/258745

Your star_indx variable variable is not holding the correct values. After the end of the loop, it is holding a value 256 which is giving an error with substr function.
Cross check your code with the video