displaying the mem address of chars + char arrays
-
I can do the following with 'int' with ease: 1: get the address of the pointer 2: get the contents of the pointer (the address it points too) 3: get the value of the variable pointed too. int *a; int b = 'B'; cout <<"address of b (the var) = " <<&b <
-
I can do the following with 'int' with ease: 1: get the address of the pointer 2: get the contents of the pointer (the address it points too) 3: get the value of the variable pointed too. int *a; int b = 'B'; cout <<"address of b (the var) = " <<&b <
Modify the code as follows. It should serv your purpose. void main(){ char *a; char b = 'B'; a = &b; cout <<"address of a = " <<&a <
-
Modify the code as follows. It should serv your purpose. void main(){ char *a; char b = 'B'; a = &b; cout <<"address of a = " <<&a <
Can you please explain this to me: (unsigned long)(*(&a)) thanks :doh:
-
Can you please explain this to me: (unsigned long)(*(&a)) thanks :doh:
a contains address of b. But if you say cout << a, it won't print the contents of a ( i.e address of b). But you know it is address i.e. unsigned long type, so force it to print conent of a as an address. Actually referencing & derefrerncing in the statment is not required. i.e (unsigned long)(*(&a)) is same as (unsigned long)(a)
-
a contains address of b. But if you say cout << a, it won't print the contents of a ( i.e address of b). But you know it is address i.e. unsigned long type, so force it to print conent of a as an address. Actually referencing & derefrerncing in the statment is not required. i.e (unsigned long)(*(&a)) is same as (unsigned long)(a)
hmmm, yes that makes much more sense, thanks!:)