0
Can anyone explain me about 'sizeof' and 'pointer'?
I still confusing what it can do
5 ответов
+ 4
Use sizeof to know how much space in memory a data type or variable takes (in bytes).
int a;
cout << sizeof(a) << endl;
cout << sizeof(int) << endl;
A pointer contains an address, and can access the stuff it points to.
int a = 42;
int *p = &a; //& is the address-of operator
cout << p << endl; //prints the address of a
cout << *p << endl; //* dereferences a pointer and access the value pointed
*p++;
cout << a << endl; //a has been changed via the pointer
+ 1
sizeof is use to know the size of any datatype and pointer is use to save the value of address of any variable
+ 1
Can I get The example?
0
pointer is just an variable (named storage space) which stores address of another variable as it value...
for example : if ur father has a plot somewhere and he named it xyz.... and u hv a document which content only address of that xyz ! then ur document is an pointer... pointing that xyz plot ! I know its a very bad example.. but I found it very suitable !
0
Thx three guys I understand all three advice for now