T O P
icjeremy

Looks like you're passing in ints, not strings. What is the type of "tab"? Edit: And if tab really is an array of strings, tab\[j\]\[k\] will be a char.


douts589

tab is an array of strings. and yeah tab\[j\]\[k\] is a char i can't convert it to an int with stoi??


icjeremy

Nope. stoi takes a string as input, which is an array of chars. You could create a string having that single char and pass that, but that's not ideal. Instead, the standard trick is to use char subtraction. That is, to convert the chars '0' through '9' to their integer equivalents, subtract the char '0' from them. This works because e.g. in ascii, '0' is encoded as value 48 and, say, '9' is encoded as 57, so '9'-'0'=57-48=9.


douts589

thnx that worked :)