You wrote that line without thinking about types. s is a string, s[i] is a char. char has no method c_str(). If you wrote s.c_str()[i] it would be fine and work exactly like s[i]. The argument that atoi wants is char*, while you only give it char.
What my line does is map ascii values of digits '0', '1', '2', ... = 48, 49, 50, ... to actual numbers 0, 1, 2, ..., obviously by subtracting '0' = 48.