title: C: How to make fgets read a \n line break from a file?
body: <p>I have a program (console), where I put all the text in a separate .txt file.</p>
  
  <p>I use <code>fgets()</code> to read a string from the file, but when the file contains a \n and I later print the string, it prints \n instead of a linebreak</p>
  
  <p>Here is an example:</p>
  
  <pre><code>FILE* fic = NULL;
  char str[22]; //str is the string we will use
  
  //open the file
  fic = fopen ("text.txt", "r");
  
  //read from the file
  fgets(str, size, fic);
  
  printf(str);
  </code></pre>
  
  <p>If this is what I have in my text.txt:</p>
  
  <pre><code>This is \n an example
  </code></pre>
  
  <p>However what comes out on the console is</p>
  
  <pre><code>This is \n an example
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>This is 
   an example
  </code></pre>
  
  <p><strong>Edit:</strong>
  in the file it's written as \n. I also tried addint \ or \t in the file but it would print \ and \t instead of a tabulation or a single back-slash</p>