Scor­pio News

  

October–December 1988 – Volume 2. Issue 4.

Page 15 of 35

Operators

The standard operators are all available in C, but there are some interesting notes. The logical operators are called & (and), | (or) and ^ (xor). Also available are && and || which perform logical (as opposed to bitwise) AND and OR. These operators have the very useful feature that they do not evaluate the second argument if there is no need. For example,

mflg && !timeout()

will not evaluate !timeout() (logical not of function timeout()’s result) if mflg is false.

The equality operator is “==” to to distinguish from the assignment operator. There are a set of useful shorthand-notations for amendment assignments. For example, we need not write:

total = total + entry

because we can use

total += entry

Similarly we can have -=, *=, /=, &= etc. Also available are ++ and –– which increment or decrement the value to which they are attached. If they occur before the reference they operate before the value is taken otherwise the operate after. Thus if a=2 and b=5,

a++ + b++ == 7           ++a + ++b == 9

Input & Output

As mentioned earlier, there are no input or output commands as such in C. However, the standard function library should contain a good selection. All I/O is handled through “streams” which can be the keyboard, a printer, the screen, a disk file or whatever, Under UNIX, all console I/O is treated as a group of streams which can consequently be redirected if desired. UNIX allows stdin and stdout (the default console streams) to be redirected on the command line which invokes the program. Since CP/M does not do this, the extent to which this particular feature is supported will depend on the implementation. HiSoft will operate correctly providing the program calls a standard library function “cpm_cmd_line()” before doing anything else. The compiler used to compile the Gemini utilities I mentioned earlier does not support command line redirection.

Page 15 of 35