Cognex Interview Question

Explain *a++ = *b++ (i.e. what does it mean, how it works)

Interview Answers

Anonymous

Aug 2, 2017

The equivalent code to the above snippet is: *a = *b; //copy value of b to a a++; //increment pointer a b++; //increment pointer b

5

Anonymous

Jul 12, 2017

The value of a is incremented by 1 after *a++, but value of b is assigned later to it using equals. So, no matter the current value of a, the new value of a should be equal to current value of b. Also, the value of b is incremented at *b++. So for example, current value of *a = 0 or anything else and *b =3 then the new value will be *a = 3 and *b=4.

1