I'm running into this (short) code and I'm not sure what it exactly does;
int amount = 5
int totalAllocatedMemory = 0;
totalAllocatedMemory += amount, malloc(amount);
It seems that 'malloc' has no effect here!
Thanks
I'm running into this (short) code and I'm not sure what it exactly does;
int amount = 5
int totalAllocatedMemory = 0;
totalAllocatedMemory += amount, malloc(amount);
It seems that 'malloc' has no effect here!
Thanks
It does have an effect, in that it allocates memory. However, the code does look bizarre and the memory does get leaked.
In case you're wondering about the syntax and exact semantics, see How does the Comma Operator work
It:
totalAllocatedMemroy
(typo?)Well the code looks buggy but here's what it does:
This is because comma has the lowest precedence of all operators in C.