Update 'cv3/program.c'
This commit is contained in:
parent
0ac9d77192
commit
2f3fc5ad8a
@ -24,10 +24,13 @@ int main(void) {
|
||||
str[strlen(str) - 1] = 0;
|
||||
// if number
|
||||
if(strlen(str) > 1 || (str[0] >= '0' && str[0] <= '9')) {
|
||||
char *p;
|
||||
errno = 0;
|
||||
float res = strtod(str,&p);
|
||||
my_exit(str[0] == '.' || errno || (*p) != 0, "bad input");
|
||||
my_exit(str[0] == '.', "bad input");
|
||||
float res = 0.f;
|
||||
int dots = 0;
|
||||
for(int i = 0; i < strlen(str); i++)
|
||||
if(str[i]=='.') dots++;
|
||||
else my_exit(str[i] < '0' || str[i] > '9', "bad input");
|
||||
res = atof(str);
|
||||
stack_push(p_stack, res);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user