Dan snippet code:
int a [5] = {1,3, -5,4,2}, n = 5, * p, * q, a = 0, b = 0, c = 0;
for (p = a + n-1; p & gt; = a; p--)
IF (P & GT; A + 1 & amp; & amp; p & lt; a + 3)
q = p;
a = * q; b = * (Q-1);
Task Such:
Calculate the values of all variables in a specified fragment of the program when running each line.
But when I try to run debugging, it gives such a mistake:
C4703-Potentially uninitialized local variable indicator “Q”
What is the problem and how can it be solved?
Answer 1
Everything is simple, you did not initialized p
and q
Replace the initialization string, to such:
int a [5] = {1,3, -5,4,2}, n = 5, * p = nullptr, * q = nullptr, a = 0, b = 0, c = 0 ;