void test_check_operators() { //TODO : tester la taille de la chaine des opérateurs test(check_ops("()+-*/%")); test(check_ops("()+-*/%^") == 0); test(check_ops("((+-*/%") == 0); test(check_ops("(+-*/%") == 0); }
int main(int ac, char **av) { char *expr; unsigned int size; char *final; if (ac != 4) { my_putstr("Usage : "); my_putstr(av[0]); my_putstr(" base ops\"()+-*/%\" exp_len\n"); exit(1); } check_base(av[1]); check_ops(av[2]); size = my_atoi(av[3]); expr = get_expr(size); final = eval_expr(av[1], av[2], expr, size);
int main(int ac, char **av) { char *expr; unsigned int size; if (ac != 4) { my_putstr("Usage : "); my_putstr(av[0]); my_putstr(" base ops\"()+-*/%\" exp_len\n"); return (0); } if (check_base(av[1]) == 1) return (0); if (check_ops(av[2]) == 1) return (0); size = my_atoi(av[3]); expr = get_expr(size); if (expr == NULL) return (0); my_putstr(eval_expr(av[1], av[2], expr, size)); my_putstr("\n"); return (0); }
/* ** Main function. Given by the subject. ** When you use this program to compute very large numbers, use the -p ** parramater to enable progress bar display. ** Ex : ./calc "01" "()+-x/%" 999999999 -p */ int main(int ac, char **av) { unsigned int size; char *expr; int p; p = 0; if (ac != 4 && ac != 5) { my_putstr("Usage : "); my_putstr(av[0]); my_putstr(" base (\"0123456789\") ops (\"()+-*/%\") exp_len\n"); exit(1); } else if (ac == 5 && strcmp(av[4], "-p") == 0) p = 1; check_base(av[1]); check_ops(av[2]); size = my_atoi(av[3]); expr = get_expr(size); eval_expr(av[1], av[2], expr, size, p); free(expr); exit(0); }