Can anyone explain me about 'sizeof' and 'pointer'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone explain me about 'sizeof' and 'pointer'?

I still confusing what it can do

16th Sep 2016, 3:49 AM
JS of MC(not C++ || java)
JS of MC(not C++ || java) - avatar
5 Answers
+ 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
16th Sep 2016, 9:31 AM
Zen
Zen - avatar
+ 1
sizeof is use to know the size of any datatype and pointer is use to save the value of address of any variable
16th Sep 2016, 3:57 AM
Sunny Bundel
Sunny Bundel - avatar
+ 1
Can I get The example?
16th Sep 2016, 4:48 AM
JS of MC(not C++ || java)
JS of MC(not C++ || java) - avatar
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 !
22nd Sep 2016, 6:28 PM
chitralekha kachhawa
chitralekha kachhawa - avatar
0
Thx three guys I understand all three advice for now
23rd Sep 2016, 5:04 AM
JS of MC(not C++ || java)
JS of MC(not C++ || java) - avatar