Hey guys. I am working on fixing old code for my work. It is currently written in C ++. They converted the static distribution to dynamic, but did not edit memsets / memcmp / memcpy. This is my first programming internship, so hungry with my new question, somehow.
The following code is in C, but I want to have it in C ++ (I read that malloc is not good practice in C ++). I have two scenarios: first, we created f. Then you use & f to fill with zero. The second is the * pf pointer. I am not sure how to set pf for all 0, as in the previous C ++ example.
Can you just do pf = new foo instead of malloc and then call memset(pf, 0, sizeof(foo)) ?
struct foo { ... } f; memset( &f, 0, sizeof(f) );
c ++ memset memcmp
garry
source share