Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Asking if elements in struct arre zero
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="James Hu, post: 1684009"] [good stuff snipped] If you knew for sure that struct mystruct did not have any padding bits (and you can not portably determine this), or if you knew that struct mystruct is always initialized in a way such that all its padding bits are zero (such as allocated by calloc(), or was initialized by a call to memset(p, '\0', sz)), you could have used the function memcmp(). { static const struct mystruct z; if(memcmp(&mystruct1, &z)) { print("All elements of mystruct1 is zero"); } } But, Richard's suggestion is the most straight forward and less error prone. -- James [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Asking if elements in struct arre zero
Top