I have a function called strToInt that accepts a string of characters and converts it to an integer:
insertI am trying to add to this function so that it detects a '-' as the first character in the string and converts the string to a negative number instead. How would I implement that? Thanks for any help!Code:int strToInt (const char str[]) { int i, intValue, result = 0; for (i = 0; str[i] >= '0' && str[i] <= '9'; ++i) { intValue = str[i] - '0'; result = result * 10 + intValue; } return result; }