Jimmyee

|
Joined: 12th Jul 2008
Location: Idk :P
|
|
[C++] How to clean char variable? |
|
|
Does anyone know, how to clear char variable? I need to do it in My proxy, because packet lengths are fucked up.
I have to clean buffer( char recvbuff[1024] ) after I receive packet.
~EDIT 1:
NVM fixed.
void clearCharBuff(char *buf)
{
for(int x=0;x<1024;x++)
{
buf[x]='\0';
}
}
|
|
|
|
|
|
Neo
|
Re: [C++] How to clean char variable? |
|
|
Lol..You don't need to write a function to "clean a char buffer."
char buff[4] = {0};//Initializes a char buffer at 0. Looks like [0][0][0][0][0].
char buff2[4];//Initializes a char buffer with random data. Looks like [rand][rand][rand][rand][rand].
If you want to set a char buffer that's already been initialized to 0, use memset.
memset(buff2, 0, 4);//Set all chars in buff2 to 0. Looks like [0][0][0][0][0].
|
|
|
|
|
|
Westside Rep
|
Joined: 2nd Nov 2006
Location: Tampa, Florida
|
|
Re: [C++] How to clean char variable? |
|
|
|
Jimmyee

|
Joined: 12th Jul 2008
Location: Idk :P
|
|
Re: [C++] How to clean char variable? |
|
Ok ty, I just wanted to clear buffer for packets in My proxy.
|
|
|
|
|
|
Funwhendrunk

|
Joined: 28th Mar 2009
Location: Florida
|
|
Re: [C++] How to clean char variable? |
|
Westside Rep posted: (24th May 2009 01:18 pm)
gtfo
|
|
|
|
|
|