We have a lot of duplicate code that looks like this: 

```
void WriteA(A *to, A *from);
void WriteB(B *to, B *from);
void WriteC(C *to, C *from);

void WriteA(A *to, A *from){
    *to = *from;
}

void WriteB(B *to, B *from){
    *to = *from;
}

void WriteC(C *to, C *from){
    *to = *from;
}

```

Even though C doesn't have function overloading or templates, I'd like to make this a single generic function. I suppose my only option here, is to use void pointers. 

```
void Write(void *to, void *from);

```

---

However, there doesn't seem to be a way to derive the type once inside the function: 

```
void Write(void *to, void *from){
    *to = *from
}

```

*compiler error: illegal type(s): void '=' void*

---

There also doesn't seem to be a way to pass a third parameter which is a typename(again, something I assume only C++ can do with templates).

How would I go about writing this kind of function? I'd like to avoid the pre-processor if possible. 

---

I thought I could maybe do this: 

```
void Write(void *to, void *from){
    memcpy(pTo, pFrom, sizeof(*pTo));
}

```

but,  

*compiler error: don't know size of object*