uninitialized local variable used c++

  c++, pointers, struct

Why can’t I initialize the integer variable num with the value of the number field of the Strct structure?

#include <iostream>

struct Strct
{
    float number = 16.0f;
};

int main()
{
    Strct* strct;
    int num = strct->number;
    return 0;
}

Error List: C4700 uninitialized local variable 'strct' used

Source: Windows Questions C++

LEAVE A COMMENT