in reply to Re: OT: Why does malloc always give me 24?
in thread OT: Why does malloc always give me 24? [SOLVED]
C99 has variable-length arrays (VLAs), which would allow this, where gizmo would be on the stack and evaporate on do_something's return:
void do_something(int n) { struct acme gizmo[n]; int i; for (i=0; i<n; i++) { /* do stuff */ } }
The code above has a syntax error: gizmo* = (acme*)malloc(sizeof(acme) * N) has an unnecessary "*" after "gizmo".
|
|---|