It's
malloc
, please see:
http://www.cplusplus.com/forum/articles/416/[
^].
Please don't forget
free
.
Why do you thing your allocation should be dynamic? You don't have variable number of structures; in your code, it's the
immediate constant 4, which is, by the way, always bad. You should have explicit
const
. In this case, you can simply declare the array, and it will be allocated on stack and not removed until you leave for a upper-level stack frame.
—SA