Hi, Code: struct Buffer { unsigned char pkt[4092]; }; struct Buffer *start; start=(struct Buffer *)malloc(sizeof(struct Buffer)); unsigned char *pkt=(unsigned char *)malloc(4092*(sizeof(unsigned char))); memcpy(&start->pkt,&pkt,len); //Where 'len' is the length of a packet that is stored in 'pkt'. OUTPUT: Segmentation fault This code does not show error when compiled but gives error on running. I tried all in the following but it give same segmentation fault error every time. memcpy(&start->pkt,&pkt,len); memcpy(start->pkt,&pkt,len); memcpy(start->pkt,pkt,len); It's a bit long code but I only need help in memcpy so that I have pasted the relevant lines. I need to copy the data that is in this 'pkt' to the 'start->pkt' of length 'len'. Appreciate any suggestions or help.
I did not understand it but when i use sizeof(pkt) instead of len, error does not come. What can be the reason. I want to copy data from 'pkt' to 'start->pkt' but of length len and sizeof(pkt) and len are not same.