Click here to Skip to main content
12,629,107 members (35,259 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.5K views
Posted

How to zero your memory?

, 23 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
I always use a home-made macro to zero my struct's and class's:#define ZEROMEMORY ZeroMemory (this, sizeof (*this))Sample1:struct S1 { double x; long i; char s[255+1]; S1 () { ZEROMEMORY; } };Sample2:class foo { private: double x[16]; char a,b,c; foo () {...
I always use a home-made macro to zero my struct's and class's:
#define ZEROMEMORY ZeroMemory (this, sizeof (*this))
Sample1:

struct S1 { double x; long i; char s[255+1]; S1 () { ZEROMEMORY; } };

Sample2:
class foo {
 private:
   double x[16];
   char a,b,c;
   foo () { ZEROMEMORY; }
};

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jose David Pujo
Software Developer (Senior) Freelancer
Spain Spain
No Biography provided

You may also be interested in...

Comments and Discussions

 
Generalhow to add the number Pin
eg_Anubhava11-Nov-11 3:31
membereg_Anubhava11-Nov-11 3:31 
GeneralReason for my vote of 2 This is to dangerous. Another progra... Pin
Martin Richter [MVP C++]12-Sep-11 20:57
memberMartin Richter [MVP C++]12-Sep-11 20:57 
GeneralReason for my vote of 5 Nice one. Pin
Malli_S9-Sep-11 1:32
memberMalli_S9-Sep-11 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 23 Aug 2011
Article Copyright 2011 by Jose David Pujo
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid