title: C strcpy_s - Buffer is too small && 0 error
body: <p>I have buffer problem on this line 
      strcpy_s(*(pWords + word_count), word_length, pWord); 
      I'm trying to read a file from argv[1] and print out every single word in that file and their occurrence, but I can't figure out whats wrong..?!?</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      char *delimiters = argv[2];                     // Prose delimiters
      char buf[BUF_LEN];                                       // Buffer for a line of keyboard input
      size_t str_size = INIT_STR_EXT;                          // Current memory to store prose
      char*  filePath = argv[1];
      FILE *fP ;
      char* pStr = malloc(str_size);                           // Pointer to prose to be tokenized
      *pStr = '\0';                                            // Set 1st character to null
      fopen_s(&amp;fP, filePath, "r");
      fread(buf, BUF_LEN, 10, fP);
  
  
  
  
  
      size_t maxWords = 10;                                     // Current maximum word count
      int word_count = 0;                                       // Current word count
      size_t word_length = 0;                                   // Current word length
      char** pWords = calloc(maxWords, sizeof(char*));          // Stores pointers to the words
      int* pnWord = calloc(maxWords, sizeof(int));              // Stores count for each word
  
      size_t str_len = strnlen_s(buf, BUF_LEN);                // Length used by strtok_s()
      char* ptr = NULL;                                          // Pointer used by strtok_s()
      char* pWord = strtok_s(buf, delimiters, &amp;ptr);  // Find 1st word
  
      if (!pWord)
      {
          printf("No words found. Ending program.\n");
          return 1;
      }
  
      bool new_word = true;                                     // False for an existing word
      while (pWord)
      {
          // Check for existing word
          for (int i = 0; i &lt; word_count; ++i)
          if (strcmp(*(pWords + i), pWord) == 0)
          {
              ++*(pnWord + i);
              new_word = false;
              break;
          }
  
          if (new_word)                                            // Not NULL if new word
          {
              //Check for sufficient memory
              if (word_count == maxWords)
              { // Get more space for pointers to words
                  maxWords += WORDS_INCR;
                  pWords = realloc(pWords, maxWords*sizeof(char*));
  
                  // Get more space for word counts
                  pnWord = realloc(pnWord, maxWords*sizeof(int));
              }
  
              // Found a new word so get memory for it and copy it there
              word_length = ptr - pWord;      // Length of new word
              *(pWords + word_count) = malloc(word_length);         
              strcpy_s(*(pWords + word_count), word_length, pWord); // Copy to array
              *(pnWord + word_count++) = 1;                         // Increment word count
          }
          else
              new_word = true;                                      // Reset new word flag
  
          pWord = strtok_s(NULL, delimiters, &amp;ptr);      // Find subsequent word
      }
  </code></pre>