You've put the second jdeStrncpy inside the inner if block, but it should be just after it.
The algorithm can be simplified a little bit:
Code:int j = 0; bool in_dups = false; for (int i = 1; i < N; ++i) { if (input[i] == input[i - 1]) { if (!in_dups) { in_dups = true; result[j++] = input[i - 1]; } result[j++] = input[i]; } else in_dups = false; }