Take out this line from the end of the function:
checked = 1;
And replace it with this:
return(checked);
}
Then, look at your code - it's not the check that is wrong now, it's the init_array.
Try this:
int main()
{
printf("Main started\n");
int arr[100];
init_array(arr, 20, 1, 15);
printf("Init complete\n");
int x = check_array(arr, 20);
printf("%u\n", x);
return 0;
}
Run you app and look at what you get printed:
Main started
Is all you get.
So, why doesn't it exit from init_complete?
Simple: it never gets out of your
do
...
while
loop, so i never gets increased. And because the array is initialized to zeros, it will automatically find a match every time it tries to check ...
Have a look with the debugger and see if you can see what I mean.