View Single Post
Old 18 December 2019, 18:50   #8
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,671
Quote:
Originally Posted by a/b View Post
Yeah, it's legal. It's the same as:
Code:
char* x = NULL;
if (...) {
  x = "whatever";
}
y(x);
Not really. Here you are just assigning x with a constant string pointer. This string is usually not temporarily allocated on the stack.
Deimos' example is some C99-thing. It doesn't work with C89.

Quote:
Originally Posted by deimos View Post
What should happen to the { 0, 1 }? Where is it? In the functions stack frame? Or is it created within the if statement's block?
It's in the stack frame, allocated on function entry.

Quote:
Originally Posted by deimos View Post
Code:
    kludge = (WORD []) { x, y };
Isn't legal, right?
Didn't test it, but I would guess it works. The structure is initialized during the if-statement, so its contents might also be variable (?).
phx is offline  
 
Page generated in 0.04379 seconds with 11 queries