I'm trying to learn using pointers, and in the code below I can send variables to a function.
But the return is obviously wrong and I can't seem to figure it out.
What I want the function to return is the number of even number occurrences.
Any suggestions to where I go wrong would be much appreciated.
I've tried to comment to indicate where I'm struggling, although I'm sure you would see it anyway.
#include <stdio.h>
int countEven (int* numbers)
{
int even[7];
int i=0, j=0;
for(i=0;i<7;i++)
{
if(numbers[i]%2 == 0)
{
even[j]=numbers[i];
j++;
}
}
printf ("%i\n", j); //Checking if function works
return;
}
int main (void)
{
int numbers[] = {2, 5, 10, 16, 31, 17, 30};
int size=7;
int j=0;
countEven(&numbers);
printf ("%i\n", countEven(numbers)); //return output causing problems
system ("pause");
return 0;
}