I'm trying out the memcpy.c implementation after understanding the code and the need for byte transfer or word transfer depending on the data received.
#include<stdio.h>
void* my_memcpy(void*,const void*,int); // return type void* - can return any type
struct s_{
int a;
int b;
};
int main(){
struct s_ ss,dd;
ss.a = 12;
ss.b = 13;
printf("\n sizeof(struct) : %d \n",sizeof(ss));
my_memcpy(&dd,&ss,sizeof(ss));
printf("\n a:%d b:%d \n",dd.a,dd.b);
return 0;
}
void* my_memcpy(void* s,const void* d,int count){
if(((s | d | count) & (sizeof(unsigned int)-1)0)){
char* ps = (char* )s;
char* pd = (char* )d;
char* pe = (char* )s + count;
while(ps != pe){
*(pd++) = *(ps++);
}
}
else{
unsigned int* ps = (unsigned int* )s;
unsigned int* pd = (unsigned int* )d;
unsigned int* pe = (unsigned int* )s + count;
while(ps != pe){
*(pd++) = *(ps++);
}
}
}
Error : Invalid operands to binary | (void* and const void*).
I could not or a void* with const void*.
In the question I asked earlier in Understanding the implementation of memcpy() its typecasted to (ADDRESS).
What can be done to solve this error?