title: Trash elements in array [C]
body: <pre><code>    while (arr[i] != '\0')
          {
              if (((arr[i] == '/' &amp;&amp; arr[i + 1] == '*') || 
                  (arr[i] == '*' &amp;&amp; arr[i + 1] == '/') || 
                  (arr[i] == '*' &amp;&amp; arr[i - 1] == '/') || 
                  (arr[i] == '/' &amp;&amp; arr[i - 1] == '*')) 
                  || (arr[i] == ' ' || arr[i] == '\t' || arr[i] == '\r' ||
                      arr[i] == '\n' || arr[i] == '\v' || arr[i] == '\f'))
                  flag_char = 0;
  
              if (arr[i] == '/' &amp;&amp; arr[i + 1] == '*' &amp;&amp; flag_comment == 0)
                  flag_comment = 1;
  
              if (arr[i] == '*' &amp;&amp; arr[i + 1] == '/' &amp;&amp; flag_comment == 1)
                  flag_comment = 0;
  
              if (flag_comment == 1 &amp;&amp; flag_char == 1)
              {
                  characters++;
                  flag_char = 1;
  
              }
              else
                  flag_char = 1;
              i++;
         }
  </code></pre>
  
  <p>So i'm trying to count the characters in a multi line comment. If i do something like /* asd */ it counts 3 characters, but if i do</p>
  
  <pre><code>/*
  asd
  */
  </code></pre>
  
  <p>It won't count any characters, because of some trash elements the array is filled with. When it gets to 'a'arr[i-1] shows some character instead of \n.
  How can i get rid of it? I'm getting the characters with fgets:</p>
  
  <pre><code>while (fgets(arr, 100, stdin) != NULL)
          {
              if (strstr(arr, "Terminate")) break;
              getCount(arr); // that's my function name
          }
  </code></pre>