Use a standard library function like atoi() or strtol().
If you want to talk about the correct way to WRITE the atoi() function, that's a different matter, and actually quite a bit more difficult than writing the reverse function. Consider first the sub-problem of determining when a string represents a valid integer representation.