• Twitter
  • Facebook
  • Google+
  • Instagram
  • Youtube

Monday, 15 August 2016

The Use of * and & in C/C++

The Use of * and & in C

by

 

The use of * in C
(a)   Multiplication:   x = y*z;
(b)    Multiply-assign:   x *= y;   Means the same as: x = x*y;
(c)   Comments:   /* your comment here */
(d)   Pointer declarations:   int *p; or int* p;   Read: p is a pointer to an int.
(e)   Compound pointers:   int **p; or int** p;   Read: p is a pointer to a pointer to an int.
(Also int ***p; and so on.)
(f)   De-referencing:   x = *p;   Read: Assign to x the value pointed to by p.
The use of & in C
(a)   Logical-and:   if ( ( a>1 ) && (b<0) ) ...
(b)   Bitwise-and:   x = a&b;   Corresponding bits are and'ed (e.g. 0&1 -> 0)
(c)   Bitwise-and-assign:   x &= y;   Means the same as: x = x&y;
(d)   Address-of operator:   p = &x;   Read: Assign to p (a pointer) the address of x.
The additional use of & (in parameters) in C++
 

0 comments:

Post a Comment

Contact

Get in touch with me


Adress/Street

Jozi Studio -Sydney, New South Wales

Phone number

+(12) 3456 789

Website

www.learnwithjoe.blogpost.com.au