#include <stdio.h>
#include <stdlib.h>

typedef struct { int num_tel, nbr_appel, cout; } Client;

void initClient(Client *pClient, int num_tel, int nbr_appel, int cout);
Client* createData();

#define NBCLIENT 20

void initClient(Client *pClient, int num_tel, int nbr_appel, int cout)
{
  pClient->num_tel = num_tel;
  pClient->nbr_appel = nbr_appel;
  pClient->cout = cout;
}

Client* createData()
{
  Client *clients = malloc(NBCLIENT * sizeof (Client));
  /** @bug check for NULL pointer missing! */
  for (int i = 0; i < NBCLIENT; ++i) {
    int numeroTel = 600000000 + (rand() % NBCLIENT);
    int prixAppel = (rand() % 400) + 1;
    initClient(clients + i, numeroTel, 1, prixAppel); 
    /* &clients[i] would've worked as well as clients + i */
  }
  return clients;
}

int main()
{
  Client *clients = createData();
  for (int i = 0; i < NBCLIENT; ++i) {
    Client *pClient = clients + i; /* or: &clients[i] would work as well */
    printf("%2d.: %d, %d, %d\n",
      i, pClient->num_tel, pClient->nbr_appel, pClient->cout);
  }
  free(clients);
  return 0;
}
