|
-
June 17th, 2002, 11:44 AM
#1
memset to null a buffer
I am using a character buffer repeatedly. For example to converti integer numbers to ascii. How do I null out the buffer if I use it over and ove. I know about memset, but I don't know what to copy into the variable using memset. Should I just copy the '\0' character into the first position using memset? Is '\0' the correct
character to fill it with?
So for example char buffer[1024];
How do I null out this buffer using memset.
Thank you for your help.
-
June 17th, 2002, 01:26 PM
#2
char buffer[1024];
memset( (void *)&buffer, '\0', sizeof(buffer));
-
June 18th, 2002, 02:24 AM
#3
The simplest way!
template <class T>
void ZeroMem(T& oData)
{ memset(&oData, 0, sizeof(T));}
void main()
{
struct oRec {...};
oRec Rec;
char szBuff[1024];
ZeroMem(szBuff);
ZeroMem(Rec);
}
-
June 19th, 2002, 12:27 AM
#4
Hi...the character '\0' and 0 is the same thing... so if u use memsetmemset(buffer, '\0', 1024); or memset(buffer, 0, 1024); ...it actually means the same thing....u can verify this in ur debug window...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|