title: Using memset to set an array
body: <p>I am a newbie to C still, and I am having a problem with the memset function.</p>
  
  <p>I pass a char * to a function, and inside this function I create an array, and then use memset to set each value. I have been using dbx to watch this variable as it enters the function, and for some reason it gets set to "" after we pass memset.</p>
  
  <p>Firstly, why does this happen? I'm assuming that memset must be resetting the memory where the char * is located? </p>
  
  <p>Secondly, is there a better way to set each element as "0"?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>static char *writeMyStr(char *myStr, int wCount) {
  
     // here myStr is set to "My String is populated"  
  
     char **myArr;
     myArr = (char **) malloc(sizeof(char *) * wCount);
     memset(myArr, 0, sizeof(char *) * wCount);   // myStr is set to ""
  
     ... populate array ... 
  
  }
  </code></pre>