Character arrays
Dan KoGai
dankg at volcano.Berkeley.EDU
Thu Jul 5 19:17:06 AEST 1990
In article <13281 at ulysses.att.com> srn at ulysses.att.com (Shirish R Nadkarni) writes:
>Does anyone have a piece of code that can scan a formula ? I will
>try to explain that a bit:
>
>Suppose I have 4 numbers (these will be stored in variable names, but
>for the time we will assume that they are stored under 1, 2, 3 and 4).
>I need to calculate
>
>total = 1 * 2 + 3 * 4 OR (1*2) + 3 + 4 OR 1 + (2/3) +4
Take a look at the source of expr: expr is a unix utility that
does exactly what you want: You give formula as an arguments, which
symobols and numbers separated with space.
I had to do if from scratch in my CS cource. Maybe it's a good
practice if you do it by yourself. It was quite benefitial for me. But
precedence handling was pain in the neck...
----------------
____ __ __ + Dan The "expr 1 / 0" Man
||__||__| + E-mail: dankg at ocf.berkeley.edu
____| ______ + Voice: +1 415-549-6111
| |__|__| + USnail: 1730 Laloma Berkeley, CA 94709 U.S.A
|___ |__|__| + Oxymorons: Usable MS-DOS is oxymoron.
|____|____ + Multitasking Mac is oxymoron.
\_| | + Secure Unix is oxymoron
More information about the Comp.lang.c
mailing list