C/C++の宿題を片付け ..
244:デフォルトの名無しさん
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;
}
次ページ最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5315日前に更新/123 KB
担当:undef