ZT: http://www.cppblog.com/zhangyq/archive/2009/01/06/71385.html
let's take a look at the following Code :
char array [12];
memset (array, 0, strlen (array);
int result = 0;
If (! Array)
{< br> result = 1;
}< br> Program is executed to the end, the value of result is still 0.
the memset function prototype is void * memset ( void * DEST , int C , size_t count ) ; it only sets the values of all elements in the memory block of DeST to C, it is not to set DEST to null (although null is defined as 0); null is a special type and its value is '/0 ', we can regard it as a pointer constant, but it is never null. The Compiler protects it. Most of us use it as a boundary condition. Memset (array, 0, strlen (aarray) only initializes the memory occupied by array with 0 instead of setting array to null; memset is only for the value of elements in a memory block, rather than the address. To set the result value to 1, the condition must be changed from array to array [0]. it is also important to note that we cannot change constants, otherwise an error will be reported, so when writing: char * Ch = "1234"; memset (CH, 0, strlen (CH), although the compilation can pass, but cannot run. The memset function uses the value transfer method to pass the parameter, because it is illegal to assign a constant to a variable, this will change the content of the constant.