Operators - Casio FX-890P Owner's Manual

Casio personal computer owner's manual
Table of Contents

Advertisement

You can also use a pointer within a character string to isolate single characters from
the string.
/* Pointer example */
/* #include <stdio.h> */
main(){
char *p;
p="Casio";
printf("%c %s¥n",*p,p);
}
Execution of this program will produce the following result:
This is because a string is actually a pointer to the first character, the "null" character
(0) being added after the last character to close the string.
Now, lets assume we want to access the third letter of the string "Casio". We need to
increment the pointer p by 2. *(p+2) is character "s".
Because p was declared as pointing toward characters (see line 4), the interpreter
knows that an increment of 1 will select the next Byte in the memory.
If p were pointing toward long integers, each increment would select the next 4
Bytes.
As said earlier arrays are closely related to pointers as well.
int a[5], *pa
pa=a; /* equivalent to pa=&a[0] */
pa++; /* now, pa points toward a[1] */

6.2 Operators

C employs many operators not available with BASIC, FORTRAN or Pascal.
Operators are represented by such symbols as "+", "-", "*" and "/", and they are used
to alter values assigned to variables. Basically, the C interpreter supports the same
operators as a standard ANSI C compiler.
Precedence
When a single expression contains a number of operators, precedence determines
which operator is executed first. Note the following:
a+b*c
In this case, the operation "b*c" is performed first, and then the result of this is added
to "a". This means that the precedence of multiplication is higher than that of addition.
Note the following example:
(a+b)*c
In this case, the (a+b) operation is performed first, because it is enclosed within
parentheses.
C Casio
>_
108

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents