title: Deleting string from array of strings (C)
body: <p>I have an array of pointers (char**) which contain some strings. The array ends with an empty string ('\0'). I am supposed to search for a specific word in that array of strings and delete the whole line (ofc using realloc and shortening the array of strings). I'm having hard time doing this, I keep getting 'bad ptr' error.</p>
  
  <p>My code:</p>
  
  <pre><code>void deleteSentence(char **text){
      char *word,*fptr;
      int i=0;
      word=(char*)calloc(BUFFER,sizeof(char));
      printf("Enter word to delete sentences:\n");
      gets(word);
      while(text[i][0]!='\0'){
          char *str=(char*)malloc((strlen(text[i])+1)*sizeof(char));
          strcpy(str,text[i]);
          fptr=strtok(str,DELIM);
          while(fptr!=NULL){
              if(strcmp(fptr,word)==0){
                  int j=i;
                  while(text[j][0]!='\0'){
                      text[j]=(char*)realloc(text[j],(strlen(text[j+1]))*sizeof(char));
                      strcpy(text[j],text[j+1]);
                      j++;
                  }
                  free(text[j]);
              }
              fptr=strtok(NULL,DELIM);
              if(fptr!=NULL)
                  i++;
          }
      }
  }
  </code></pre>
  
  <p>Help much appreciated :)</p>