D
D
Dmitry Korolev2018-01-27 18:44:14
C++ / C#
Dmitry Korolev, 2018-01-27 18:44:14

What's the problem with loop execution?

for (long dd = alen - da - 1; dd < alen; dd++)
    {
      printf("%ld dd, %ld alen\n", dd, alen);
      a[dd] = a[dd + 1];
    }

The program crashes in this cycle, why?
the variable and the condition are fine, and the crash occurs. the pointer is in place, and its size is normal

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-01-27
@adressmoeistranici

Here:
a[dd + 1]
array out of bounds on the last iteration of the loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question