Using Designated Initializers with the Heap

前端 未结 2 1842
被撕碎了的回忆
被撕碎了的回忆 2020-12-11 07:23

One can use designated initializers as shown below (for \"billy\") without issue, but when the same initialization approach is used on dynamic memory things wil

2条回答
  •  醉梦人生
    2020-12-11 08:20

    You have to write:

    *molly_ptr = (struct student){
                                    .name = "molly",
                                    .age = 25
                                 };
    

提交回复
热议问题