Warning: X may be used uninitialized in this function

后端 未结 3 1128
悲哀的现实
悲哀的现实 2020-12-23 09:21

I am writing a custom \"vector\" struct. I do not understand why I\'m getting a Warning: \"one\" may be used uninitialized here.

This is my vector.h fil

3条回答
  •  轮回少年
    2020-12-23 10:01

    When you use Vector *one you are merely creating a pointer to the structure but there is no memory allocated to it.

    Simply use one = (Vector *)malloc(sizeof(Vector)); to declare memory and instantiate it.

提交回复
热议问题