finding size of variable without using sizeof()This tip submitted by Rajesh punia on 2006-11-21 00:30:19. It has been viewed 12622 times.Rating of 5.6 with 81 votes Here's a trick for finding the size of a variable without using sizeof--not something you'd generally do, but it demonstrates the ability to use pointer arithmetic. This trick is highly dependent on the layout your compiler uses for stack variables though! int a,int b char *p1,*p2; p1=(char*)a; p2=(char*)b; p1-p2 More tips Help your fellow programmers! Add a tip! |