title: Strange segmentation default
body: <p>The problem I want to solve is: Count the number of occurrences of key words in a C code. Here's the code:</p>
  
  <blockquote>
    <p>The problem is that I get a segmentation fault. In my code I mentioned where
    is the problem. Can you, please, explain me why ?</p>
  </blockquote>
  
  <p><em>In header:</em></p>
  
  <pre><code>struct Chei
  {
      char *cuv;
      int contor;
  };
  
  typedef struct Chei chei;
  
  int ReadCode(char *a[]);
  void  determine(chei *Ch, char *temp, int size);
  void Frequency(chei *Ch, int nr_lines, char *a[], int size);
  </code></pre>
  
  <p><em>In main:</em></p>
  
  <pre><code>    chei tab_chei[] = {{"while", 0},{"if", 0}, {"case", 0}, {"switch",  0}};
      int size = sizeof(tab_chei)/sizeof(tab_chei[0]);
      char *Code[MaxL];
      int nr_lines;
  
  
      nr_lines = ReadCode(Code);//number of lines of text
  
      Frequency(tab_chei, nr_lines, Code, size);
  </code></pre>
  
  <p><em>In function file:</em>
  <em>I think there is no problem with reading text (function ReadCode() -- here I allocated memory for each Code[i] using malloc). I used an array of pointers to char for this.</em></p>
  
  <pre><code>// This functions determines if the word "temp" is a keyword, and increases
       //"contor" if it is.
  
  void  determine(chei *Ch, char *temp, int size)
  {
      int i;
  
  
      for (i = 0; i &lt; size; ++i)
      {
          if (!strcmp(Ch[i].cuv, temp))
          {
              Ch[i].contor++;
              break;
          }
      }
  }
  </code></pre>
  
  <p>Array "a" contains the text.</p>
  
  <pre><code>void Frequency(chei *Ch, int nr_lines, char *a[], int size)
  {
      int i;
      char temp[MaxCh];
      char *token = 0;
  
  
          strcpy(temp, a[0]);//I put a[0] as a particular case
          token = strtok(temp, " ");
          determine(Ch, token, size);
  
          while (token != NULL)
          {
  
              token = strtok(NULL, " ");
              determine(ch, token, size); //here is the problem.
  //I observed that if I delete this line, there is no error
  //but still it isn't what I want to get
          }
  
          for (i = 0; i &lt; size; ++i)
              {
                  printf("\n%-10s%-4d", Ch[i].cuv, Ch[i].contor);
              }
  
  }
  </code></pre>