Useful Function or Junk?
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Errmm...it's junk, sorry! You have problem with the way you calculate the size of the buffer: sizeof(szBuffer) will reduce to sizeof(char *) which is the size of a pointer - NOT the size of the buffer that it points to. So, you have to introduce a new parameter to specify the size at runtime. You might as well use ZeroMemory defined in windows.h which does this exact thing: VOID ZeroMemory(VOID *buf, SIZE_T length); And it's clearer what it does too :-) Regards, James
http://www.catch22.uk.net -
Personally I think a function this simple is better suited to be a macro (or an inline function). As it stands right now, you have introduced the added overhead of an additional function call, without any additional benifit. Nothing wrong with the idea in my oppinion though.
the reason why I have the function cast that way is because without the char * szBufferName convention, you woudl have to defin ethe size of the buffer within memset itself, when it's far simpler to just use the pointer and still get the same effect. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
Personally I think a function this simple is better suited to be a macro (or an inline function). As it stands right now, you have introduced the added overhead of an additional function call, without any additional benifit. Nothing wrong with the idea in my oppinion though.
After reading a following post I went back and saw what you did. I think what you wanted was strlen(), but that only works for null terminated strings (Rarely what you are dealing with in the situation you described).
-
the reason why I have the function cast that way is because without the char * szBufferName convention, you woudl have to defin ethe size of the buffer within memset itself, when it's far simpler to just use the pointer and still get the same effect. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
What effect are you talking about? All your function does is sets the first 4 (in the case of 32bit pointers) bytes of your buffer to 0. sizeof(szBufferName) does not give you the size of the string pointed to by szBufferName, it gives you the size in bytes of the pointer itself.
-
After reading a following post I went back and saw what you did. I think what you wanted was strlen(), but that only works for null terminated strings (Rarely what you are dealing with in the situation you described).
I used sizeof because theres no guarentee that your -going- to get a null terminated string, so i figured it made sense, at least on my level of understanding. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
I used sizeof because theres no guarentee that your -going- to get a null terminated string, so i figured it made sense, at least on my level of understanding. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Well sizeof does not give you what you want.
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
This only works if the buffer size is know at compile time. Works:
char buf[256];
memset(buf, 0, sizeof(buf));This does NOT work:
Zero(char* buf)
{
memset(buf, 0, sizeof(buf));
}main()
{
char buf[256];
Zero(buf);
}Todd Smith
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Is it a function for cleaning up 4-byte strings (Visual C++ assumed) ? Use ZeroMemory Win32 macro instead. Concussus surgo. When struck I rise.
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Oh, almost forgot: you can do this (not my invention, this is a classic one): template class CWin32Struct : public T { public: CWin32Struct() { ZeroMemory(this, sizeof(T)); }; }; template class CWin32StructCB : public T { public: CWin32StructCB() { ZeroMemory(this, sizeof(T)); cb = sizeof(T); }; }; then use: CWin32Struct pi; or CWin32StructCB pmc;
-
This only works if the buffer size is know at compile time. Works:
char buf[256];
memset(buf, 0, sizeof(buf));This does NOT work:
Zero(char* buf)
{
memset(buf, 0, sizeof(buf));
}main()
{
char buf[256];
Zero(buf);
}Todd Smith
I'm sorry, but that's simply not correct. I've tested it both ways and it works if the array is defined as szSomeArray[17] = "testtesttesttest" or szSomeArray[] ="testtesttesttest". The effect is the same. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
I'm sorry, but that's simply not correct. I've tested it both ways and it works if the array is defined as szSomeArray[17] = "testtesttesttest" or szSomeArray[] ="testtesttesttest". The effect is the same. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
That's because you are testing it the wrong way: printf(szSomeArray). Try printf(szSomeArray + 6) instead Concussus surgo. When struck I rise.
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Just do it when you declare your array:
TCHAR szSomeString[14] = {0};
That zeros out the entire array. (Actually, it sets the first element in the array to 0 (the value specified) and then C initializes the remainder of the array to 0 (regardless of the value specified).) --Mike-- Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Personally, I never use char *, because I program C++ rather than C, and I never need the performance that would justify the clunkiness and error prone nature of char *. Apart from that, I agree with the person who said that if I needed to use something so ugly as a char*, I'd be too worried about efficiency to be adding the cost of a function call ( although it's concievable that the compiler would inline it ), and I would just call memset rather than add the cost of another function. It's one line vs. one line. Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
-
I'm sorry, but that's simply not correct. I've tested it both ways and it works if the array is defined as szSomeArray[17] = "testtesttesttest" or szSomeArray[] ="testtesttesttest". The effect is the same. It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
I just tested it and it failed. Without the right test you can't get the correct answer :)
void LiquidPlumber(char * szBufferName)
{
int size = sizeof(szBufferName);
memset(szBufferName, 0, size);
}main()
{
char buf[256];
LiquidPlumber(buf);char\* array = new char\[256\]; LiquidPlumber(array);
}
Step through and see what size is. Todd Smith
-
This only works if the buffer size is know at compile time. Works:
char buf[256];
memset(buf, 0, sizeof(buf));This does NOT work:
Zero(char* buf)
{
memset(buf, 0, sizeof(buf));
}main()
{
char buf[256];
Zero(buf);
}Todd Smith
Try this.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber(char * szBufferName)
{
int size = sizeof(szBufferName);
memset(szBufferName, 0, size);
}int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char strDataToEncode[] = "testtesttesttest";MessageBox(NULL, strDataToEncode, "Clogged Pipe", MB\_OK); LiquidPlumber(strDataToEncode); MessageBox(NULL, strDataToEncode, "Cleaned Pipe", MB\_OK); return 0;
}
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Well, except for the fact that it doesn't work, has a non-descriptive name, has no error checking facilities.. no, it's not of much value. You don't work as a professional programmer I hope.
-
Try this.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber(char * szBufferName)
{
int size = sizeof(szBufferName);
memset(szBufferName, 0, size);
}int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char strDataToEncode[] = "testtesttesttest";MessageBox(NULL, strDataToEncode, "Clogged Pipe", MB\_OK); LiquidPlumber(strDataToEncode); MessageBox(NULL, strDataToEncode, "Cleaned Pipe", MB\_OK); return 0;
}
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Failed. Todd Smith
-
Try this.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber(char * szBufferName)
{
int size = sizeof(szBufferName);
memset(szBufferName, 0, size);
}int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char strDataToEncode[] = "testtesttesttest";MessageBox(NULL, strDataToEncode, "Clogged Pipe", MB\_OK); LiquidPlumber(strDataToEncode); MessageBox(NULL, strDataToEncode, "Cleaned Pipe", MB\_OK); return 0;
}
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
It's very convenient to have a function that takes less arguments than memset. But since it does not do the job (note that sizeof(char*) is always 4 under Win32, no matter what is the length of the actual string), then you could skip the first argument as well: void OptimizedLiquidPlumber(void) { // Nothing to do, still almost as good as the original LiquidPlumber } ;P Vagif Abilov MCP (Visual C++) Oslo, Norway
-
this is a little something I wrote because I had idle hands a little bit ago and needed something to do. Excuse the, how should I say, rather droll nature of the function name, but that happened to be the commercial airing at the time I was working on another project, hence the naming. I figured this might have some use so I went ahead and posted it, however simplistic it may seem.
/////////////////////////////////////////////
//
// Liquid Plumber: Buffer Cleanup Function
//
// function takes 1 parameter which is the
// variable name of the char array to act on.
// this is just a simple wrapper around the
// memset function to allow "hands-free" use
//
/////////////////////////////////////////////void LiquidPlumber( char * szBufferName )
{
memset(szBufferName, 0, sizeof(szBufferName));
}My question is this, is this a useful function by way of that facts that it brings the amount of work down to just specifying the variable name to act on, or is it simpler and more "syntax" correct to simply call memset? The function handles calculating the size of the buffer internally and also specifies a zero value as the character to fill the buffer with. IMHO, I think it's easier to use this function as it saves repeated calls to memset in programs where multiple buffers are used, and in most cases, filling the buffer with a zero value, especially if it's in a program like a server app thats using a buffer as temp storage for commands recieved from a tcp/ip port. It would be easier to call this than to have to manually code the values. Comments / Suggestions Appreciated.
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now... [Shog9 on Kid Programmers]
Use the following and be done with it: *szBufferName = '\0'; I see code all the time when folks zero out strings for no reason. They waste processor time and their own. I had a friend who told me once that he worked with a contractor that zero'ed out every string by using a for-loop. Clever...