Special Operators In C

Special Operators

  • The Comma Operator
  • Type cast Operator
  • Reference operator or Address Operater ("&")
  • Dereference operator ("*") or Pointer Operater
  • Double Pointer operator ("**")
  • sizeof operator

The Comma Operator

  • The Comma operator  can be used to link the related expressions together.

Example For Comma Operator

Comma Operator In for Loops
for(i=0,j=1;i>10:i++,j++)

Comma Operator In while Loops

While(c<10,c--)

Type cast Operator

Syntax:

( type )

Explanation

  • converts a to the specified type.
  • Note that the use of a parenthesized type in a method declaration or definition is not an example of the use of the type cast operator.

Example For Type Cast Operator

float s= 12.5;        int a;
a = (int) s;
now a value is 12.

Reference operator or Address Operater ("&")

The reference operator noted by ampersand ("&"), is also a unary operator in c languages that uses for assign address of the variables. It returns the pointer address of the variable. This is called "referencing" operater. 

Syntax

data_type x;
data_type *pt;
pt = &x

Example : Reference operator ("&") and Dereference operator ("*")

Dereference operator ("*") or Pointer Operater

The dereference operator or indirection operator, noted by asterisk ("*"), is also a unary operator in c languages that uses for pointer variables. It operates on a pointer variable, and returns l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer. 

data_type *pt;

Example : Reference operator ("&") and Dereference operator ("*")

Double Pointer operator ("**")

Double Pointer is, that double pointer points to another pointer variable address.

data_type **pt;

sizeof operator

sizeof returns the size of a variable or datatype

sizeof (data_type)

Example :Pointer and Sizeof Usage