Code :
- typedef struct _info {
- int present ;
- int nbparam ;
- } InfoArg;
- void Record(InfoArg *argument, int position, int *last_arg_position, InfoArg *last_argument) {
- if (argument->present !=0) {
- exit(1);
- }
- if (last_argument == NULL) {
- argument->present = position ;
- last_argument = argument ;
- }
- else {
- argument->present = position ;
- last_argument->nbparam = argument->present - last_argument->present ;
- last_argument = argument ;
- }
- }
- void PrepareArg(int nb_arg, char *liste_arg[], InfoArg *liste_param){
- /* nb_arg = argc, *liste_arg[] = argv, liste_param l'adresse d'un tableau de InfoArg*/
- printf(" inside the analyse\n" );
- InfoArg *last_arg=NULL ;
- int nb = nb_arg ,
- last_pos=0 ;
- printf(" debut boucle for\n" );
- for (nb = 1 ; nb < nb_arg ; nb++){
- if (*liste_arg[nb]=='-');
- switch (*++liste_arg[nb]) {
- case 'm' :
- Record(&liste_param[0], nb, &last_pos, last_arg);
- break;
- case 'f' :
- Record(&liste_param[1], nb, &last_pos, last_arg);
- break;
- default :
- printf(" insde teh switch\n" );
- break;
- }
- }
- }
|