title: Saving top score in a file
body: <p>So I want to save the best 3 scores of the game and to put them on a file. But for some reason when I read the file the best scores are 53,32,32. Not using name for now, just the 3 scores. And also I'm not familiarized with files.</p>
  
  <pre><code>typedef struct score{
      unsigned char score[3];
      //char name[20];
  } SCORES;
  </code></pre>
  
  <p>This is how I'm saving. </p>
  
  <pre><code>void guardar_highscore (SCORES top){
  
  FILE *f;
  
  f = fopen ("/var/www/html/highscore3.txt","wb");
  if (f ==NULL)
      perror ("nope2"),exit (1);
  fprintf(f,"%d \n %d \n %d \n",top.score[0],top.score[1],top.score[2]);
  
  fclose(f);
  }
  </code></pre>
  
  <p>This is how I'm reading it to the struct.</p>
  
  <pre><code>SCORES ler_highscore (){
  SCORES top={0};
  int i=0;
  char line[20];
  
  FILE *f;
  f = fopen ("/var/www/html/highscore3.txt","rb");
  if (f ==NULL) 
      perror ("nope"), exit (1);
  
  while(fgets(line,20, f) != NULL){
      sscanf (line, "%c", &amp;top.score[i]);
      i++;
  }
  fclose(f);
  
  return top;
  }
  </code></pre>