0

My code for find.c is working fine. I checked with other examples other than on the problem set. I implemented binary search using recursion and changed the search function to include beginning and end of the array. When I do check50, all examples are evaluated correctly but there is a compile error - \ expected an exit code of 0, not standard error of "helpers.c:17:6: error: conflicting type...". Can anybody tell me what is this?

1

When you say you changed the search function... do you mean you changed the arguments? check50 uses the find.c program that you were given. You can't change the function declaration in helpers.c to not match how find will be calling search().

If you need to change the arguments, do something like:

bool search (int value, int values[], int n)
{
    // declare and initialize the extra arguments here

    // use those arguments in a new function
    return mySearch( ...  )
}

and then write your recursive search as a new function and simply return it to the given search.

1

I ran into the same problem. It turns out that the issued was caused by declaring a new function and declaring its prototype in helpers.h. For some reason, if I instead declared the prototype in helpers.c, the error was gone. Clearly this shouldn't happen, it seems to be a bug in the checking process.

Hope this helps someone.

2
  • Thank you! Spent a precious hour debugging this exact problem. Suspected an issue with the grading program as my tests worked fine, but would not have figured out the workaround if it weren't for your post. Hopefully the CS50 folks can correct this!
    – user6276
    Feb 21 '15 at 13:51
  • This is exactly what I'm looking for. It's remarkably strange that the check50 throws a compilation error when a new function prototype is declared inside helpers.h, though, the program works correctly in gdb mode.
    – Pooja
    Apr 29 '16 at 21:37

You must log in to answer this question.

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