I am trying to find out if there is an alternative way of converting string to integer in C.
I regularly pattern the following in my code.
char s[] =
int atoi(const char* str){ int num = 0; int i = 0; bool isNegetive = false; if(str[i] == '-'){ isNegetive = true; i++; } while (str[i] && (str[i] >= '0' && str[i] <= '9')){ num = num * 10 + (str[i] - '0'); i++; } if(isNegetive) num = -1 * num; return num; }