#include <iostream>

void* my_find(void *key, void *array, int ElementSize, int n)
{
  bool match = false;
  char *KeyCOPY = (char*)key;
  char *ArrayCOPY = (char*)array;
  for (int i = 0; i < n; i++) 
  {
    for (int Element = 0; Element < ElementSize; Element++)
    {
      if (*KeyCOPY != *ArrayCOPY)
      {
        match = false;
        break;
      }
      else {
        match = true;
      }
      KeyCOPY++;
      ArrayCOPY++;
    }
    KeyCOPY = (char*)key; // BUG: What about ArrayCOPY in the case of false match??? 
    if (match == true)
    {
      for (int i = 0; i < ElementSize; i++)
      {
        ArrayCOPY--;
      }
      return ArrayCOPY;
    }
  }
  return NULL;
}

char TAB[] = { 'A','B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' };

int main()
{
  void* tab = TAB;

  char x = 'D';

  std::cout << my_find(&x, TAB, sizeof(char), 10);   // Wrong answer
  return 0;
}

