Atoi.h
int myAtoi(char *str)
{
	if (*str == 0) return 0;

	int res = 0; // Initialize result
	int sign = 1; // Initialize sign as positive
	int i = 0; // Initialize index of first digit

  for (; str[i] != '\0'; ++i)
	{
		if(str[i] == ' ' && res == 0) continue;
		else if(str[i] == '-' &&  res == 0) sign = -1;
		else if(str[i] == '+' &&  res == 0) sign = 1;
		else if(isNumericChar(str[i]) == false) break;
		else res = res*10 + str[i] - '0';
	}
	// Return result with sign
	return sign*res;
}
// A simple atoi() function. If the given string contains
// any invalid character, then this function returns 0
A simple atoi() function. If the given string contains
any invalid character, then this function returns 0
A simple atoi () function . If the given string contains any invalid character then this function returns 0
int myAtoi(char *str)
{
	if (*str == 0) return 0;
	int res = 0; 
	int sign = 1; 
	int i = 0; 
  for (; str[i] != '\0'; ++i)
	{
		if(str[i] == ' ' && res == 0) continue;
		else if(str[i] == '-' &&  res == 0) sign = -1;
		else if(str[i] == '+' &&  res == 0) sign = 1;
		else if(isNumericChar(str[i]) == false) break;
		else res = res*10 + str[i] - '0';
	}
	return sign*res;
}
int myAtoi ( char * str ) { if ( * str == 0 ) return 0 ; int res = 0 ; int sign = 1 ; int i = 0 ; for ( ; str [ i ] != ' \0 ' ; ++ i ) { if ( str [ i ] == ' ' && res == 0 ) continue ; else if ( str [ i ] == ' ' && res == 0 ) sign = -1 ; else if ( str [ i ] == ' ' && res == 0 ) sign = 1 ; else if ( isNumericChar ( str [ i ] ) == false ) break ; else res = res * 10 + str [ i ] - ' ' ; } return sign * res ; }
A simple atoi() function.
A simple atoi () function .
// Initialize result // Initialize sign as positive // Initialize index of first digit // Return result with sign