|
-
Mar 28th, 2002, 02:24 AM
#1
clear buffer in c + how to invert something?
in continuation from previous post..
Is there a function in C to clear a buffer?
anything at all.
2nd question:
a rough idea: how can we invert a bytestream? or a block of data of any size...
basically, the data has to be sent across the network, and the network data structure requires the bytestream be inverted. SO how to go about doin' that?
Last edited by mendhak; Mar 28th, 2002 at 02:33 AM.
-
Mar 28th, 2002, 07:35 AM
#2
What do you mean clear a buffer?
There is
Code:
char szBuffer[32];
memset( szBuffer, 0, sizeof(buffer) / sizeof(char) );
or
Code:
char szBuffer[32];
ZeroMemory( szBuffer, sizeof(buffer) / sizeof(char) );
Basically the same thing...
and for your second question take a look at these fuctions: htons(), htonl(), ntohs(), ntohl()... They might help.
-
Mar 28th, 2002, 10:24 AM
#3
Also you can completely clear the buffer from memory like thisL:
Code:
char *buf;
buf = (char*) malloc(10000);
// code here, then nuke the buffer
free(buf);
// or use new and delete (standard C++)which is like malloc and free.
-
Mar 28th, 2002, 12:48 PM
#4
Thanks. Just what was needed.
-
Mar 29th, 2002, 02:30 AM
#5
Fanatic Member
Beware of malloc and free (ie new and delete)..... You CANNOT free a buffer that was not created with malloc (or new). The result could be tragic!!
Regards,
MoMad
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
|