I am trying to test my search function by creating a separate function that takes an input [some integer] and then checks whether that integer fits within the given array [numbers 10-19].
I made the array within a main function
int main(void)
{
int values[ 10 ]; /* n is an array of 10 integers */
int g;
/* initialize elements of array n to 0 */
for (g = 0; g < 10; g++ ) {
values[ g ] = g + 10; /* set element at location i to i + 10 */
printf("%i", values[g]);
}
printf("\n");
}
I then have the Bool linear search function after:
bool search(value, int values[],int m) {
// TODO: implement a searching algorithm
for (int i = 0; i < m; i++)
{
if ( value == values[i])
return true;
}
return false; }
However, I have struggled to find a way to actually find a way to give an input for value.
I wanted to do something like:
int main(int argc, string argv[]) {
string num = argv[1];
int value = atoi(num);
However, this returns unused parameter and unused variable errors. I can't put the Bool function within main either. What can I do?