Copy struct to struct in C

前端 未结 7 1760
北荒
北荒 2020-11-27 14:06

I want to copy an identical struct into another and later on use it as a comparance to the first one. The thing is that my compiler gives me a warning when Im doing like thi

7条回答
  •  感动是毒
    2020-11-27 14:35

    memcpy expects the first two arguments to be void*.

    Try: memcpy( (void*)&RTCclk, (void*)&RTCclkBuffert, sizeof(RTCclk) );

    P.S. although not necessary, convention dictates the brackets for the sizeof operator. You can get away with a lot in C that leaves code impossible to maintain, so following convention is the mark of a good (employable) C programmer.

提交回复
热议问题