When checking my find program with check50 I get a :( frown at the second check, which is:
helpers.c compiles. expected exit code 0, not 1
The log file gives me additional info:
running clang -std=c11 -o find find.c helpers.c -lcs50 -lm... checking that program exited with status 0...
I don't know why I get that since my program compiles just fine with make all (as well as make find).
The program (including recursive binary search and counting sort) seems to work as expected. Following tests were successful:
./generate 1000 50 > numbers.txt // generate 1000 numbers including 127
./find 127 < numbers.txt // Found needle in haystack!
./find 128 < numbers.txt // Didn't find needle in haystack.
The following modifications were made to the source files:
/**find.c:*/
const int MAX = 65536; // this expression was removed
.
/**helpers.c:*/
bool search(int value, int values[], int n)
{
//...
return bisearch(value, values, left, right, n);
}
bool bisearch(int value, int values[], int left, int right, int n)
{
if (left > right)
return false;
//...
if (values[middle] == value)
return true;
//...
return bisearch(value, values, left, right, n);
}
void sort(int values[], int n)
{
/...
return;
}
.
/**helpers.h:*/
#define MAX 65536 // this expression was added to replace const int MAX
bool search(int value, int values[], int n);
bool bisearch(int value, int values[], int left, int right, int n);
void sort(int values[], int n);
check50
may be using its own copy ofhelpers.h
and only looking at yourhelpers.c
. Try moving your#define MAX
to the top ofhelpers.c
. It may be failing compilation when it runs into the symbolMAX
. In most of these assignments, it is important to modify only the files they specifically ask you too. Anything else may cause issues with the autograder.