| 1 |
/* |
| 2 |
* File: sexpr.c |
| 3 |
* Purpose: evaluate algebraic expression from single argument |
| 4 |
* (Derived from expr.c from J.T. Conklin <[email protected]>.) |
| 5 |
* Version: 1.0 (Nov 1995) |
| 6 |
* Author: Piet Tutelaers |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
#include "strexpr.h" /* strexpr() */ |
| 11 |
#include "basics.h" /* fatal() */ |
| 12 |
|
| 13 |
int main(int argc, char *argv[]) { |
| 14 |
int result; |
| 15 |
|
| 16 |
if (argc < 2) fatal("Usage: sexpr expression ...\n"); |
| 17 |
|
| 18 |
while (--argc > 0) { |
| 19 |
if (strexpr(&result, *++argv)) |
| 20 |
fatal("expression error\n"); |
| 21 |
|
| 22 |
printf("%s = %d\n", argv[0] , result); |
| 23 |
} |
| 24 |
exit(0); |
| 25 |
} |