You are changing the value of pk
in the loop for (pk = 0; pk < pp; pk++)
. This means that it will be pp
afterwards. In fact, this loop is quite useless in its current state as it destroys the old k
, and gives it a value of substring(0, 1)
pp
times. So k
will be size 1.
Since pp
is bigger than 1, you get an invalid index.
6
solved if i input more than 1, i got force close [closed]