0

helpers.c

I'm having a bit of difficulty in compiling the helpers.c program. Specifically when I try to check the correctness of the program, it seems it cannot find the needle 127 in the haystack of 1000 random numbers, referring to "./generate 1000 50 | ./find 127" . Any ideas on what I may have done wrong?

  • 1
    Except for a minor flaw, the search code appears correct. It should be finding 127. More likely, there's a problem with the code that loads the numbers in the array. Try working with a smaller data set, maybe 10 elements, and print out the array to see if it is loading correctly. Also, you should know that you will never check the last element in the array because of a code bug that is in your search() function. – Cliff B Jul 4 '15 at 17:44
  • Thanks, It turns out that I had to recompile find.c. – Dylan Savoury Jul 5 '15 at 17:11
1

Asked and answered in comments.

Except for a minor flaw, the search code appears correct. It should be finding 127. More likely, there's a problem with the code that loads the numbers in the array. Try working with a smaller data set, maybe 10 elements, and print out the array to see if it is loading correctly. Also, you should know that you will never check the last element in the array because of a code bug that is in your search() function. – Cliff B Jul 4 '15 at 17:44

Thanks, It turns out that I had to recompile find.c. – Dylan Savoury Jul 5 '15 at 17:11

| improve this answer | |

You must log in to answer this question.

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