12.3 THE * OPERATOR
The unary operator * is known as indirection operator or dereferencing operator. When we apply it to a variable say p we write *p and pronounce simply as “star p”. By *p we understand a variable pointed by p. Therefore, p must be a variable declared as pointer variable. To declare any variable as of type pointer, it has to be declared as
int *p ;
Here int is the type declarator. Variable p points to variable of type int. If you want a pointer to float, you can declare float *p; If we have an ordinary variable (not declared as pointer) as say int i; we cannot apply * to i. “*i” will produce compilation error. Also we cannot apply * to any expression. Thus, *(2+4) will be illegal. Let us write a simple program.
Problem: Write ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access