title: C - Reads new line in a .txt
body: <p>I am making a program that reads a file and counts how many words the .txt have. The program is working just fine, the problem is that if the txt have a break line it stops reading, so i have to put all my text in one line. As far as i know the problem is in fgets, that stops reading when it reaches EOF or a new line. My question is: How do i reads my text even with new lines ? Do i have to use fread() ? If so, would i do? Below is the part of the code where i read the .txt and put in an array.</p>
  
  <pre><code>char linha[10000];
  int grandezaStrings = 100000;
  int i = 0;
  int contadorString = 0;    
  
      //  This line reads the file.
      fgets (linha, grandezaStrings,myFile);
  
      // Used for special characters
      setlocale (LC_ALL,"PORTUGUESE");
  
      // Dynamic array to hold words
      char ** strings = (char **)malloc(grandezaStrings * sizeof (char*));
      char * pch;
      for (i=0;i&lt;grandezaStrings; i++){
          strings[i] = (char *)malloc(100+1);
      }
  
      // Transfer all the words to my array.
      i = 0;
      pch = strtok(linha, " ,.!?:;()\n");
      while (pch != NULL){
          strlwr(pch);
          strings[i] = pch;
          contadorString++;
          pch = strtok (NULL, " ,.!?:;()\n");
          i++;
      }
  </code></pre>
  
  <p>Thanks a lot!</p>