#include <stdio.h>

#ifdef __BIG_ENDIAN__
#define htole(x) \
     ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
      (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
#else
#define htole(x) (x)
#endif

int main(int argc, char *argv[]) {
  int i=1, t;
  char str[512];
  FILE *fp;

  /* This is all you need to write the array */
  if ((fp=fopen("num_tracks.db","wb"))!=NULL) {
    while (fgets(str,512,stdin)) {
      t = atoi(str);
      printf("%i tracks on disc %i\n",t,i++);
      t = htole(t);
      fwrite(&t,sizeof(int),1,fp);
    }
    fclose(fp);
    printf("num_tracks.db written\n");
  }
  
  return 0;

}
