this is my code and i want to do this function to be general, how i do it?
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void * DoIt (void *arr, int elemSize, int numElems, void (*f) (void *));
void Sqr (void *x);
void main( )
{
double a[3] = {1.0, 2.0, 3.0};
DoIt (a,sizeof(double),3,Sqr);
}
void Sqr (void *x)
{
*(double *)x =(*(double *)x) * (*(double *)x);
}
void * DoIt (void *arr, int elemSize, int numElems, void (*f) (void *))
{
int i;
for( i=0; i<numElems; i++)
{
if(i%2==0)
{
..........
}
}
the out put have to do the sqr function on the even numbers in array...