Can you tell me the meaning of a**=b;
in C. Also please define the **
operator;
views:
210answers:
3
+16
A:
There is no such operator (**=
) in C. It results in syntax error.
There "is" **
in C though, which is always tokenized as *
followed by a *
, e.g.
int a;
int* b;
int** d;
int c = a**b; // c = (a) * (*b)
int e =** d; // e = *(*d)
Your code a**=b
is tokenized as a
*
*=
b
, which is syntax error.
KennyTM
2010-09-27 09:35:14
What the heck is a *b?
Azz
2010-09-27 09:40:30
@Azz: `b` is a pointer to an int, and the unary `*` *dereferences* the pointer to give back an `int`. See http://en.wikipedia.org/wiki/Pointer_(computing)#C_pointers
KennyTM
2010-09-27 09:42:05
@Azz: if be is a pointer, then `*b` is the value pointed by the pointer; this is called dereferencing.
Cedric H.
2010-09-27 09:42:30
Thanks mate, I've never touched C but it just intrigued me.
Azz
2010-09-27 09:44:30
@azz: (Off topic) [C# has this too (with the same syntax)](http://msdn.microsoft.com/en-us/library/tcy5wf0h.aspx), but that is unsafe code. :)
KennyTM
2010-09-27 09:46:50
+2
A:
That type ( **) operator not aviable in c . If you use then it will give compile time error.
Anand Kumar
2010-09-27 12:59:34
Wrong... that's two pointer dereference operators as stated in another answer.
alxx
2010-09-27 13:17:06
+1
A:
Yes, there is no **=
operator in C. In C **
is used for pointer to a pointer.
example: int **a
refers to a pointer to an integer pointer. here a
stores address of an integer pointer.
Anji
2010-09-28 06:43:39