title: Can't read line written on a file in C
body: <p>I have been developing this project where every process after being forked writes his information on a file for the parent to read. 
  I have also written a small snippet for the parent to read this file, but every time I run this code it wont work. 
  Instead, when I manually write in the file in the following format:</p>
  
  <ul>
  <li>567 | A | B | 20</li>
  <li>568 | N | A | 2</li>
  <li>569 | Z | B | 12</li>
  </ul>
  
  <p>I can read allright, but when I run this code: </p>
  
  <pre><code>  #include "header.h"
  
  
    struct Individui {
         pid_t pid;
         char tipo[50];
         char nome[50];
         unsigned long genoma;
    };
  
  
  int main(int argc, char *argv[]) {
  
      Individuo individuo;
      srand(getpid());
  
      int min = 2;
      int max = atoi(argv[2]);
      int diff = max - min;
      int r;
      r = rand() % (diff + 1) + min;
  
      char randomletter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[rand() % 26];
  
      individuo.pid = getpid();
      strcpy( individuo.tipo, argv[0]);
      strcpy( individuo.nome, &amp;randomletter);
      individuo.genoma = r;
  
      FILE *f = fopen("dati.txt", "a");
      if (f == NULL)
      {
          printf("Error opening file!\n");
          exit(1);
      }
  
      fprintf(f, "%d | %s | %s | %lu\r", individuo.pid, individuo.nome, individuo.tipo, individuo.genoma);
  
      fclose(f);
  
      return 0;
  }
  </code></pre>
  
  <p>And then read the file with this code, it doesn't work:</p>
  
  <pre><code>int main(){
      char name[4], type[4];
      int pids[4];
      unsigned long genome[4];
      int i = 0;
  
      FILE * file = fopen("dati.txt", "r"); // "r" = read
      while(fscanf(file, "%d | %c | %c | %ld\n", &amp;pids[i], &amp;name[i], &amp;type[i], &amp;genome[i]) != EOF){
          i++;
      }
  
      printf ("%d %c %c %lu\n", pids[0], name[0], type[0], genome[0]);
      printf ("%d %c %c %lu\n", pids[1], name[1], type[1], genome[1]);
      printf ("%d %c %c %lu\n", pids[2], name[2], type[2], genome[2]);
  }
  </code></pre>
  
  <p>From what I was able to understand, the length of the lines I write with the process code is very long, and the code to read the file doesn't support it. I'm new to C so I can't really know where I'm mistaken, and I hope somebody might help.</p>