Sizeof | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Sizeof

Sizeof('3') = 4 How ?

24th Sep 2019, 10:18 AM
Shubham Kumar
Shubham Kumar - avatar
9 Answers
+ 5
✳AsterisK✳ that mean sizeof operator do type-casting if data type is not defined?
24th Sep 2019, 11:38 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 5
Any non-specified numeric value is an int, if it has a decimal point is a double. Then when you put this value in a variable C does a non-warning implicit cast. And that's why any library function has his one-character arguments like int, it doesn't waste computing time doing casts and with memory align.
24th Sep 2019, 12:20 PM
Miquel Andreu Fuster Sancho
Miquel Andreu Fuster Sancho - avatar
+ 4
the ascii characters are integer values, which range from 1-128 this values are integers disguised a char, which in other words means its an integer value, ascii value of 3 is 51 its just like doing sizeof(51) which is an int
24th Sep 2019, 11:02 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
'3' is converted to the ASCII value and being a 64-bit Machine int is 4 bytes in your system
25th Sep 2019, 2:01 AM
Aditya
Aditya - avatar
+ 2
Because int is 4 bytes.
24th Sep 2019, 10:21 AM
KfirWe
KfirWe - avatar
+ 2
Drissa Sidibe imagine a white paper tape, on it you can write whatever you want, but to understand something you cannot overlap information. This tape has a finite size so if you write many things on it you can run out of space to put others. That is dynamic memory, an area of memory that is left to the programmer to put in it what he wants. What is in memory will remain between function calls and between blocks of code. Is the responsibility of the programmer to erase the unnecessary or, in languages that has garbage collector, of this functionality.
1st Oct 2019, 2:50 PM
Miquel Andreu Fuster Sancho
Miquel Andreu Fuster Sancho - avatar
+ 1
Hi! Can someone help me to understand "dynamic memory" concept? Thanks!
1st Oct 2019, 2:22 PM
drissa
drissa - avatar
+ 1
Ok! Thanks you very for yor help fuster sancho !
1st Oct 2019, 2:53 PM
drissa
drissa - avatar
0
i don't know how it works Internally, am trying to look it up but can't find something genuine maybe ~ swim ~ can help us out
24th Sep 2019, 12:03 PM
✳AsterisK✳
✳AsterisK✳ - avatar