known char *cts = "hello, girl!". so what is the *cts, cts? Why?
pointer
Collapse
X
-
Look at this in C:
this says that the variable x is an int.Code:int x;
Then try:
This says the variable x and y are ints.Code:int x,y;
OK so far. Now try:
This says that the variables x,y and *z are ints.Code:int x,y,*z;
OK. Now put these definitions on separate lines:
Finally, since whitespace doesn't count, you can move the *:Code:int x; int y; int *z;
Nothing has changed. x is an int. y is an int. and *z is an int.Code:int x; int y; int* z;
With respect to *z, the variable z is called a pointer. A pointer is to contain an address. In this case z must contain the address of an int.
If you display z you see the address of the int. If you display *z you see the int.
Comment