hello,
thats maybe a stupid question but i got stuck on it. is there any way to not only declare but initialize array/pointer members in a struct or union?
hello,
thats maybe a stupid question but i got stuck on it. is there any way to not only declare but initialize array/pointer members in a struct or union?
No and yes.
You can't initialize ANYTHING in a struct or union declaration.
You can initialize into a variable declared of a struct or union type.
For example:
--Code:struct something { int x; int *ptr; }; int someint; struct something somevar = { 0, &someint };
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
my boss leaved me confused, now this make sense to me.
thanks mats for helping me out with this.
You can also use ZeroMemory or memset to 0 out everything in a struct. This is always recommended if you're not initializing the struct as outlined above (since some member may have junk data otherwise).