1.17.2
Referring to Variable of C Language
C language variables can be specified using the same descriptions as in the source
program written in C language.
■ Specifying C Language Variables
C language variables can be specified using the same descriptions as in the source program. The address of C
language variables should be preceded by the ampersand symbol "&". Some examples are shown in the Table
1.17-1.
Table 1.17-1 Examples of Specifying Variables
Regular Variable
Structure
Address of variable
Reference type
Example of Variables
int data;
Pointer
char *p;
Array
char a[5];
struct stag {
char c;
int i;
};
struct stag st;
struct stag *stp;
Union
union utag {
char c;
int i;
} uni;
int data;
int i;
int &ri = i;
CHAPTER 1 BASIC FUNCTIONS
Example of
Specifying
Variables
data
Value of data
*p
Value pointed to by p
a[1]
Value of second element of a
st.c
Value of member c of st
stp- >c
Value of member c of the structure
to which stp points
uni.i
Value of member i of uni
&data
Address of data
ri
Same as i
Semantics
29