Problème fonction getopt()
Salut à tous
je rencontre des problème avec la fonction getopt() pour avoir les options d'une commande, voici mon code ;
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <getopt.h>
/* check options */
void check_options(int argc, char *argv[])
{
int opt;
while ((opt = getopt(argc,argv,"a") != EOF))
{
switch (opt)
{
case 'a' :
printf("option a\n");
break;
default :
printf("no options : %c\n",(char)opt);
break;
}
}
return;
}
int main(int argc, char *argv[])
{
assert (argc >= 2);
// check options
check_options(argc,argv);
return 0;
} |
et le problème est que je retombe toujours sur , no options et un carré avec des 0,1 comme valeur de retour pour (char)opt
je compile grâce à ( aucun prob à la compi )
et la commande est
Merci d'avance