Hello,
I have a big struct which I want to set to 0 however I am not able to use the safememset
on that struct, I can only use it with chars. Is there a way to use safememset on a struct?
safememset
-
- Junior Member
- Posts: 4
- Joined: Tue Mar 20, 2012 11:59 pm
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
You can use a reinterpret cast to interpret the struct as an array of chars and then use that as an argument to safememset(). For example:
Code: Select all
struct foo s;
safememset((s, char[]), 0, sizeof(s));
-
- Junior Member
- Posts: 4
- Joined: Tue Mar 20, 2012 11:59 pm
Thanks Richard, that was exactly what I was looking for.