enter image description hereeveryone, i'm stuck on find/generate files, i think i wrote the right code but, the program can't find the needle, can anybody helpe me, please ?

enter image description here

  • maybe 1222 is not even there. – Mustaghees Aug 20 '15 at 16:58

Classic array overshoot problem. Look at your sort code inner for loop.

for(i=0; i<n; i++)
    if (values[i] > values[i+1])...

The values[] array has n elements, numbered from 0 to n-1. Your if statement tries to test values[i+1], but i+1 = n. You're trying to test values[n], which is beyond the end of the array. Instant error. I bet you're getting a seg fault.

Adjust your limits and it should fix this problem. No guarantees that there aren't any other issues though. ;-)

If this answers your question, please click the check mark to accept this and remove the question from the unanswered pool. Let's keep up on forum maintenance. ;-)

  • Hi! I think the problem is not the sorting, I tested this algorithm and it seems to be working properly. I'm getting problem with the search, it's just a linear search but the program can't find the needle. ;( Thanks! – Jorge Saba Aug 19 '15 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .