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;
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;
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
how about if its this
double *a[12] would that be a pointer to a pointer of type double because its an array
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
In general, the type is best understood by reading it from right to left:
[12] an array of twelve <- * pointers <- double to doubles.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I've come to think of it as kind of a spiral from the middle.
http://www.codeproject.com/cpp/compl...ight_left_rule
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
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)
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
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.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
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