I want to fill a char ** variable from a function. When I used that filled value outside the filling function, I get an error.
code 139 (interrupted by signal 11: SIGSEGV)
Here is my filling function
int read(char ** tag_ids, int * nbtag)
{
 ......
// Loop through tags
*nbtag = tagCount;
tag_ids =  (char**)malloc(tagCount * sizeof(char*));
for (idx = 0; idx < tagCount; idx++) {
    error = readtag( idx, &tagData);
      tag_ids[idx] = (char *)malloc(sizeof(char)* (tagData.epcLen+1));
      if( tag_ids[idx] == NULL) {
      printf("error \n");
      }
      strcpy(tag_ids[idx], epcStr);
      printf("strcpy length %d data %s \n", tagData.epcLen, epcStr); // data OK
      printf(" strcpy length %d data %s \n", tagData.epcLen, tag_ids[idx]); // data OK
  }
return 0;
}
When I use that function:
char ** tagid = NULL;
int nbtag;
int error = read(tagid,&nbtag);
for (int i = 0 ; i<nbtag; i++){
    printf("---> tag index : %d/%d \n", i, nbtag);
    if( tagid == NULL) {
      printf("NULL pointer \n");  // Detect pointer NULL why ???
    }
    if( tagid[i] == NULL) {
      printf("NULL pointer \n");
    }
    printf("---> tag index : %d id %s \n", i, tagid[i]); // SIGSEGV
}
I think the char ** variable in argument of my function is a copy of my original variable but I don't really understand how to fill a char ** from function .
 
     
     
    