Hey guys if i declare
does that mean px is a pointer to an intCode:int *px;
would that mean the address of &a is of pa which is a pointer to the floatCode:float *pa = &a;
Printable View
Hey guys if i declare
does that mean px is a pointer to an intCode:int *px;
would that mean the address of &a is of pa which is a pointer to the floatCode:float *pa = &a;
how about if its this
double *a[12] would that be a pointer to a pointer of type double because its an array
In general, the type is best understood by reading it from right to left:
[12] an array of twelve <- * pointers <- double to doubles.
I've come to think of it as kind of a spiral from the middle.
http://www.codeproject.com/cpp/compl...ight_left_rule
So if i have
if i sayCode:int [5] = {10,20,30,40,50}
would that give me 30Code:(x + 2)
and if i gowill that make x point to the address of 30Code:(*x + 2)
but also how about if it wasCode:*(x + 2)
Could somone elaborate more please?
Perhaps your compiler could.
Sometimes you just need to look at something a couple hundred times before it is as clear as can be.Code:#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int x[5] = {10,20,30,40,50};
int *y = (x + 2);
int z = (*x + 2);
int p = *(x + 2);
printf(" y = %p\n", (void*)y);
printf("*y = %d\n", *y);
printf(" z = %d\n", z);
printf(" p = %d\n", p);
return 0;
}
I know I have. And there are still more than a few things on the list.
Thanks mate
What i dont get is how you got 12 for Z
So does that int z = (*x+2)
x is alread pointing to the zeroth element in the array but because its a * its getting the value of x which is 10. Then adding 2 to ten.
And not incrementing where x is pointing too