Warning: X may be used uninitialized in this function

The Solution to Warning: X may be used uninitialized in this function is


one has not been assigned so points to an unpredictable location. You should either place it on the stack:

Vector one;
one.a = 12;
one.b = 13;
one.c = -11

or dynamically allocate memory for it:

Vector* one = malloc(sizeof(*one))
one->a = 12;
one->b = 13;
one->c = -11
free(one);

Note the use of free in this case. In general, you'll need exactly one call to free for each call made to malloc.

~ Answered on 2012-10-18 16:07:51


Most Viewed Questions: