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?
-
1Except 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 BCommented Jul 4, 2015 at 17:44
-
Thanks, It turns out that I had to recompile find.c.– Dylan SavouryCommented Jul 5, 2015 at 17:11
1 Answer
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