i wrote the search code that find.c calls from helpers.c and yet somehow the compiler keeps returning this results.
~/workspace/pset3/find/ $ make find
clang -ggdb3 -O0 -std=c11 -Wall -Werror -o find find.c helpers.c -lcs50 -lm
helpers.c:32:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
}
^
1 error generated.
make: *** [find] Error 1
below is my search code but i cant seem to figure out the problem.
/**
* helpers.c
*
* Computer Science 50
* Problem Set 3
*
* Helper functions for Problem Set 3.
*/
#include <cs50.h>
#include "helpers.h"
/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{
// TODO: implement a searching algorithm
int i = 0;
for(i = 0; i < n; i++)
{
int value = 0;
int values[i];
if(values[i] == value)
{
return true;
}
else
return false;
}
}
/**
* Sorts array of n values.
*/
void sort(int values[], int n)
{
// TODO: implement an O(n^2) sorting algorithm
return;
}