/* C standard */
#include <stdio.h>
#include <string.h>
 
/* extension */
#include <conio.h>
 
struct album
{
   char titre[32];
};
 
void makedvd (char const *fichierdvd)
{
   FILE *fp = fopen (fichierdvd, "rb" );
 
   if (fp == NULL)
   {
      fp = fopen (fichierdvd, "wb" );
 
      if (fp != NULL)
      {
         struct album album;
 
         *album.titre = 0;
         strncat (album.titre, "Le Sarko Show", sizeof album.titre - 1);
         fwrite (&album, sizeof album, 1, fp);
 
         *album.titre = 0;
         strncat (album.titre, "Quartier V.I.P.", sizeof album.titre - 1);
         fwrite (&album, sizeof album, 1, fp);
 
         fclose (fp);
      }
   }
   else
   {
      fclose (fp);
   }
}
 
void listedvd (char const *fichierdvd)
{
   FILE *liredvd = fopen (fichierdvd, "r" );
 
   if (liredvd != NULL)
   {
 
      struct album album;
 
      textcolor (2);
      gotoxy (2, 2);
      cprintf ("Liste des albums DVD" );
      gotoxy (2, 3);
      cprintf ("====================" );
      textcolor (6);
      gotoxy (2, 4);
      cprintf ("Artiste :" );
      gotoxy (17, 4);
      cprintf ("Titre :" );
      gotoxy (31, 4);
      cprintf ("Type :" );
      gotoxy (45, 4);
      cprintf ("Piste :" );
      gotoxy (59, 4);
      cprintf ("Anne :" );
      gotoxy (73, 4);
      cprintf ("Prix :" );
      gotoxy (2, 5);
      cprintf ("-----------------------------------------------------------------------------" );
      textcolor (15);
 
      while (fread (&album, sizeof album, 1, liredvd) == 1)
      {
         gotoxy (2, 6);
         cprintf ("%s\n", album.titre);
         getch ();
      }
      fclose (liredvd);
   }
   else
   {
      perror (fichierdvd);
   }
 
}
 
int main (void)
{
   static const char fichierdvd[] = "dvd.txt";
 
   makedvd (fichierdvd);
 
   listedvd (fichierdvd);
   return 0;
}