Be careful when storing pointers inside unions

This tip submitted by singam kiran reddy on 2006-10-26 00:54:17. It has been viewed 21590 times.
Rating of 5.6 with 167 votes

Be carefull while using pointers inside unions.

Take following scenario

char *a;
int *b;
} c;


Here memory leak will occur because in future you can not get the address stored in a to free it!

More tips

Help your fellow programmers! Add a tip!