title: reads txt from file, cut them into words, and display
body: <pre><code>#pragma warning(disable:4996) 
  #include &lt;stdio.h&gt;  
  #include &lt;string.h&gt;  
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  static WORDS heap[10000];
  int heapSize;
  
  void InitHeap()
  {
      heapSize = 0;
      heap[0].words = NULL;
      heap[0].count = -1;
  }
  
  void InsertHeap(char* string)
  {
      heapSize++;
      strcpy(heap[heapSize].words, string); 
  
      int now = heapSize;
      while (heap[now / 2].words &gt; string)
      {
          heap[now] = heap[now / 2];
          now /= 2;
      }
      strcpy(heap[now].words, string);
  }
  
  int DeleteHeap()
  {
      char* minElement, lastElement;
      int child, now;
  
      strcpy(minElement, heap[1].words);
      strcpy(lastElement, heap[heapSize--].words);
  
      for (now = 1; now * 2 &lt;= heapSize; now = child)
      {
          child = now * 2;
          if (child != heapSize &amp;&amp; heap[child + 1].words &lt; heap[child].words)
          {
              child++;
          }
          if (lastElement &gt; heap[child].words)
          {
              strcpy(heap[now].words, heap[child].words);
          }
          else
          {
              break;
          }
      }
      strcpy(heap[now].words, lastElement);
  
      return now;
  }
  
  typedef struct _WORDS {
      char    words[64];
      int     count;
  }WORDS;
  
  
  char* MakeToken(void)
  {
      int i, j;  
      static char delim[256];
      memset(delim, 0x0, 256);
  
      for (i = 1, j = 0; i &lt; 256; i++)
      {
          if (!isalpha(i)) delim[j++] = i;
      }
      return delim;
  }
  
  int main() {
      int i = 0, cur = 0;
      FILE    *pFile;
      char    readLine[1024], *ptr;
      char *token = MakeToken();
  
      InitHeap();
  
      pFile = fopen("C:\\Users\\Home\\Desktop\\dataset.txt", "r");
      if (pFile == NULL) {
          printf("File open failed.\n");
          return 0;
      }
      while (fgets(readLine, 1024, pFile) != NULL) {
          ptr = strtok(readLine, token);
          while (ptr != NULL) {
              InsertHeap(ptr);
              ptr = strtok(NULL, token);
          }
      }
  
      for (i = 0; i &lt; heapSize; i++)
      {
          cur = DeleteHeap();
          printf("%s %d\n", heap[cur].words, heap[cur].count);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Error Message : Run-Time error #3
  I want to make program that reads txt from file, cut them into words, and display on console. I make it, but it doesnt work. how to fix it?
  I think static WORDS heap&lt;- this part
  or 
  delete part is error. 
  or its path is failure.</p>