title: segmentation fault while assigning string
body: <pre><code>void getAgentInfo( char** agent_address )
  {
      #define MAX_IP_SIZE 100
      FILE *fcfg=NULL;
      char line[MAXLINE];
      char *p , *pend;
      int findlen_ips, findlen_num;
      findlen_ips = strlen (findkey_ips);
      findlen_num = strlen (findkey_num);
      int iCount = 1; //in agent array entry
      fcfg = fopen (FCFG, "r");
  
      while (p = fgets (line, MAXLINE, fcfg))
      {
          //printf ("Looking at %s\n", p);
          if (p = findval (line, findkey_num, findlen_num))
          {
              pend = p + strlen (p) - 1;  /* check last char for newline terminator */
              if (*pend == '\n')
                  *pend = 0;
              printf ("%s\n", p); /* process/parse the value */
              NumOfIp = atoi(p);
              //agent_address = (char*)calloc(NumOfIp + 1, sizeof(char));
              agent_address = new char*[NumOfIp + 1];
              for(int icount = 0; icount &lt; NumOfIp+1; icount++)
              {
                  agent_address[icount] = new char[MAX_IP_SIZE];
              }
          }
  
          if (p = findval (line, findkey_ips, findlen_ips))
          {
              pend = p + strlen (p) - 1;  /* check last char for newline terminator */
              if (*pend == '\n')
                  *pend = 0;
              printf ("addr = %s\n", p); /* process/parse the value */
              agent_address[iCount]= p; //strcpy(agent_address[iCount], p)
              //printf("agent_address[iCount++]=%s\n",agent_address[iCount]);
              iCount++;
          }
      }
  }
  </code></pre>
  
  <p>From above code I'm reading a txt file and getting values in a int var and depending on that value craeting 2d string array to store values:</p>
  
  <p>...
          char** agent_address = NULL;
          getAgentInfo(agent_address);
          TRACE_STR("\n");
          agent_address[0] = MasterCPMAddr;
  ....</p>
  
  <p>I am succesfully getting string from line <code>agent_address[0] = MasterCPMAddr;</code> but afer that when I am storing it I am getting segmentation fault; //tried with <code>strcpy(agent_address[0], MasterCPMAddr)</code> also</p>