I have to write program to find all indexes, where given element occurs. I' ve written this function:
int find(const int* tab, int size, int to_find)
{
if (size<1 || tab==NULL) return -2;
int i, counter = 0;
for (i=0;i<size;i++)
{
if (to_find==*(tab + i)) return i;
}
return 0;
}
This function only returns first occurence of element, but I want to it returns every element. How can I do this?