/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        S I M U L A T I O N   D ' U N   ' goto '   R E L A N C A N T   L E   ' main() '  :                                         */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Test :                                                                                                                     */
/*                                                                                                                                   */
/*                    Le test se fera, par exemple, a                                                                                */
/*                  l'aide de :                                                                                                      */
/*                                                                                                                                   */
/*                                      $aPout    $formatI                                                                           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xtc/goto.01$c' :                                                                                               */
/*                                                                                                                                   */
/*                    Jean-Francois Colonna (LACTAMME, AAAAMMJJhhmmss).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

int       compteur=0;

void      fonction(variable,nombre,arguments)
int       variable;
int       nombre;
char      *(arguments[]);
          {
          compteur++;
          if        (compteur <= 1)
                    {
                    printf("\n relance du main (compteur=%d,variable=%d)",compteur,variable);
                    if        (nombre >= 2)
                              {
                              arguments[2]="bonjour";
                                        /* Modification de l'argument numero 2...                                                    */
                              }
                    else
                              {
                              }
                    main(nombre,arguments);
                                        /* Relance du 'main(...)'.                                                                   */
                    printf("\n fin\n");
                    exit();
                                        /* Et on est contraint de faire un 'exit()' au retour du 'main(...)' car, sinon, la          */
                                        /* fonction 'fonction(...)' rendrait alors le controle a l'appelant qui est 'main(...)',     */
                                        /* et qui serait donc reexecute une deuxieme fois...                                         */
                    }
          else
                    {
                    printf("\n compteur=%d variable=%d",compteur,variable);
                    }
          }

main(nombre,arguments)
int       nombre;
char      *(arguments[]);
          {
          int       n;
          printf("\n");
          for       (n=0 ; n<nombre ; n++)
                    {
                    printf("   argument(%d)=\"%s\"",n,arguments[n]);
                    }

          fonction(1,nombre,arguments);
          fonction(2,nombre,arguments);
          fonction(3,nombre,arguments);
          fonction(4,nombre,arguments);
          fonction(5,nombre,arguments);
          fonction(6,nombre,arguments);
          fonction(7,nombre,arguments);
          fonction(8,nombre,arguments);
          }



Copyright © Jean-François Colonna, 2021-2023.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2021-2023.