Smart Keypad problem

Can you please tell me what is wrong in my code?

if I use char* instaed of string I am getting correct output.

@Samarth_Shah
Actually the problem is that your out string is empty initially. So when you tries to add table[digit][k] using statement out[j] = table[digit][k]; It doesn’t recognise jth index of out string. So better is initialise out string with some random string in the beginning.
Changing line 33 to string out=s; will results in correct output.

@Samarth_Shah
Please mark this doubt as resolved. You got 100 points.