Malloc struct

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 6 11:56:36 PDT 2015


On 7/6/15 2:15 PM, codenstuff wrote:
> I need to create following struct using malloc
>
> struct Map {
> int **entries;
> int rows;
> int cols;
> }
> Map *map_create(int rows, int cols) {
>    Map *that = cast(Map*)malloc(Map.sizeof);
>    that.entries = cast(int**)malloc(rows * int.sizeof);

(int *).sizeof

-Steve


More information about the Digitalmars-d-learn mailing list