11th Oct 2019, 10:18 PM
UraL
10 RĂ©ponses
+ 4
That's because operand inside the sizeof operator is not evaluated.It's evaluated only if operand is variable length array.
11th Oct 2019, 10:40 PM
Qasem
+ 2
Seems the `sizeof` operator doesn't process the expression `x = x + 20`, it only checks for and return the size (in bytes) of the data type of the operand given, which can also be a variable (still, the type is used for checking). I guess that's why <x> value isn't getting modified : )
12th Oct 2019, 3:57 AM
Ipang
+ 2
UraL because sizeof operator only wants to determine size of it's operand type (like int or float) so the expression is not important. But when we have a variable length array, we can determine it's size only after operand evaluation. note that sizeof return same value for 10 and 30. but not same for {1} and {1,2}.
12th Oct 2019, 8:58 PM
Qasem
+ 2
Expression inside sizeof operator is not evaluated, if you try to print the the value store inside 's' it print size of data type integer i. e 4 court<<s; //4
13th Oct 2019, 12:59 PM
Pooja
Pooja - avatar
+ 1
sizeof() returns the byte size of the value in the parentheses, and the byte size of an int is 10. If you put a random integer in there it will still give you 10. I don't know exactly why x is 10, but I can only guess that sizeof() converts the int to a byte.
11th Oct 2019, 10:30 PM
Odyel
Odyel - avatar
+ 1
Because you have not use of size function properly, make it senseful.
12th Oct 2019, 4:04 PM
Pushpendra Singh
Pushpendra Singh - avatar
+ 1
Kilowac sizeof(int) is 4 !!!
12th Oct 2019, 8:51 PM
UraL
+ 1
Qasem why so?
12th Oct 2019, 8:52 PM
UraL
+ 1
UraL i have no idea then
12th Oct 2019, 8:58 PM
Odyel
Odyel - avatar
+ 1
Sizeof() function returns the size of variable in it In ur case althogh function contain the expression it is not considered as it is referred only as parameter.... So previous value is printed
13th Oct 2019, 7:38 PM
Shubham
Shubham - avatar