ronreiter / interactive-tutorials

Interactive Tutorials
Apache License 2.0
4.08k stars 2.6k forks source link

CTutorial - Pointer Arithmetics: Exercise doesn't accept correct solution #628

Open TheOnion313 opened 3 years ago

TheOnion313 commented 3 years ago

On the Pointer Arithmetics lesson exercise there is a built-in loop that checks your solution. The description of the exercise requires you to add pointers to the three last elements of an integer array of length 5. You also need to use a pointer to the third element (also the first element pointer that needs to be transferred) that you are given.

The loop checks that each pointer in the array is equal to the pointer given at the beginning + i (thus since it's an array the pointer to the next element).

Although there is a solution that runs a loop 3 times and pushes pointer into the array at position i and increments pointer each time, which eventually fills the array parray correctly. The check loop provided with the exercise does not support this solution as pointer changes and points to the last element once the loop starts.