07/11/26 22:08:23
>>237
関数だけ作った
valueの使い道がわからなかった
#include <stdio.h>
#include <string.h>
#define ERROR_INT 100000000
int AsciiToInt(char *s, int *value){
int calc = 1, cnt, i, ans=0;
cnt = strlen(s);
if(cnt > 8 || cnt <= 0)return ERROR_INT;
if(*s=='+' || *s=='-'){
calc = *s=='+' ? 1 : -1;
s++; cnt--;
}
if(cnt <= 0)return ERROR_INT;
for(i=0; i<cnt; i++){
if(strchr("0123456789", s[i]) == NULL)return ERROR_INT;
ans = ans*10 + s[i]-'0';
}
return ans * calc;
}