将字符型转换为整型:
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 100
int my_atoi(char *src)
{
int flag = 1;
int result = 0;
if(*src == '-')
{
flag = -1;
src++;
}
while(*src != '\0')
{
if(*src >= '0' && *src <= '9')
{
result = result * 10 + (*src - '0');
}
else
{
break;
}
src++;
}
return result * flag;
}
int main()
{
int i;
int len;
<