MᏫᎻᎯᎷᎷᎬᎠ
.
BinaryByter
According to this table, ++a would be evaluated first
then you add a to itself, so 2 + 2 and you add that to a 4 + 1 = 5
BinaryByter
given that addition precedes assignment
BinaryByter
i think
BinaryByter
lets call the expert
BinaryByter
@ollirz
MᏫᎻᎯᎷᎷᎬᎠ
Which is better
BinaryByter
which is better?
BinaryByter
wat?
Ariana
https://en.cppreference.com/w/c/language/operator_precedence
Ariana
so it is 6
BinaryByter
dafaq?
Ariana
int a=1 a += ++a + a a += 2 + a (a=2) a += 2+2 a += 4 a = 6
BinaryByter
but why assume that a becomes 2 after the second time?
BinaryByter
oh wait
BinaryByter
yea
BinaryByter
makes sense
BinaryByter
i'm stupid
Ariana
well if you never write crippled code you wont need to know 😛
Ludovic 'Archivist'
BinaryByter
i never write crippled code
BinaryByter
thats why I don't know
klimi
Greetings devs
Mat
@linuxer4fun so it's ub :P
BinaryByter
C++ is hard
BinaryByter
xD
Ariana
int a=1 a += ++a + a a += 2 + a (a=2) a += 2+2 a += 4 a = 6
maybe clearer: mov ebx 1 add ebx 1 mov eax ebx add eax ebx add ebx eax eax is a temporary var and ebx is a
Ariana
C++ is hard
lets goto assembly
Ariana
Yay!
❤️
Anonymous
❤️
I love assembly, intel syntax c:
Ariana
I love assembly, intel syntax c:
❤️❤️❤️❤️❤️
MᏫᎻᎯᎷᎷᎬᎠ
Damn
MᏫᎻᎯᎷᎷᎬᎠ
Even myself forgot the question
Anonymous
So what about Java? How does it do it?
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
So what about Java? How does it do it?
The weird thing is Java and cxx nearly share the same rules in these kind of situations
MᏫᎻᎯᎷᎷᎬᎠ
Here is Mr.standard typing....
MᏫᎻᎯᎷᎷᎬᎠ
Lol
Anonymous
lol
MᏫᎻᎯᎷᎷᎬᎠ
Hmmm
MᏫᎻᎯᎷᎷᎬᎠ
Java evaluates the left-hand operands
MᏫᎻᎯᎷᎷᎬᎠ
But cxx evaluates the right one
MᏫᎻᎯᎷᎷᎬᎠ
Thanks
Anonymous
Weird.
SkullzBoy
Hello If i have a multithread app And add values to a array Is there any way to make a value not stay more than 5seconds?
SkullzBoy
What do you mean by not stay?
The value inside the array should not stay more than 5econds, it need to get out to a FIFO
Jakup
ok sorry
Shivang
Can upload a pic book in which i have questions it hard for me to type it
Shivang
Book is c&r
Shivang
K&r
Dima
You can’t understand what the book says?
Dima
yeah you can
Shivang
Shivang
Here the function alloc has the return type pointer to char but in else condition it is returning 0 an int Is that illegal
Dima
NULL is 0
Dima
simply nothing
Shivang
Ok
Anonymous
Yes it is legal. See it as nullptr
Stanislav
NULL is 0
nope, in C++ NULL is 0, in C - (void*)0
Dima
well I am talking about C
Dima
k&r book at least kek
Anonymous
It's a book of c language by Dennis Ritchie.. I think. Isn't it..?
Shivang
Yup
Anonymous
Yup
On which chapter you are..?
Shivang
5.4
Shivang
Address arithmetic
Anonymous
I'm on 1.5 😁😁😁
Anonymous
nope, in C++ NULL is 0, in C - (void*)0
Nope, depends on the implementation.