title: Issues in pointer to char* value
body: <p>What is the issue with this code (It is printing arr[0] correctly but I am getting issues with arr[1]... printing some weird characters):</p>
  
  <pre><code>using namespace std;
  char ** setName() {
      char * arr[2];
      for (int i=0;i&lt;2;i++)
         arr[i] = (char*)malloc(100);
      arr[0] = strdup("Robert");
      arr[1] = strdup("Jose");
      return arr;
  }
  int main()
  {
      char **arr;
      arr = setName();
      printf("First name is %s\n", arr[0]);
      printf("Second name is %s\n", arr[1]);
      return 0;
  }
  </code></pre>
  
  <p>If it matters, i am running this code in Windows using Visual Studio 8.</p>