Getopt() langage C
Résolu
LaZo61
Messages postés
53
Statut
Membre
-
LaZo61 Messages postés 53 Statut Membre -
LaZo61 Messages postés 53 Statut Membre -
Bonjour,
Je n,arrive pas a lance l,afficheur doption suivant
while ((option = getopt (argc, argv, "u:p:t")) != -1)
{
switch (option)
{ case 'u':
username = optarg;
break;
case 'd':
password = optarg;
break;
case 't':
transfer_rate = optarg;
break;
exit(0);
}
}
Je n,arrive pas a lance l,afficheur doption suivant
while ((option = getopt (argc, argv, "u:p:t")) != -1)
{
switch (option)
{ case 'u':
username = optarg;
break;
case 'd':
password = optarg;
break;
case 't':
transfer_rate = optarg;
break;
exit(0);
}
}
A voir également:
- Getopt() langage C
- Langage ascii - Guide
- Langage binaire - Guide
- Langage visual basic - Télécharger - Langages
- Pascal langage - Télécharger - Édition & Programmation
- Langage basic gratuit - Télécharger - Édition & Programmation
10 réponses
char *username;
char *password;
char *transfer_rate;
extern char *optarg;
int option;
printf("saba\n");
while ((option = getopt (argc, argv, "u:p:t")) != -1)
{
printf("nurcan\n");
switch (option)
{ case 'u':
username = optarg;
break;
case 'd':
password = optarg;
break;
case 't':
transfer_rate = optarg;
break;
}
exit(0);
}
Voila normalement si il rentre dans la boucle il doit m'affiche "nurcan" mais il ne le fait pas donc il ne rentre pas dans la boucle c'est ce que je n'arrive pas a comprendre pourquoi ???
Merci d'avance
char *password;
char *transfer_rate;
extern char *optarg;
int option;
printf("saba\n");
while ((option = getopt (argc, argv, "u:p:t")) != -1)
{
printf("nurcan\n");
switch (option)
{ case 'u':
username = optarg;
break;
case 'd':
password = optarg;
break;
case 't':
transfer_rate = optarg;
break;
}
exit(0);
}
Voila normalement si il rentre dans la boucle il doit m'affiche "nurcan" mais il ne le fait pas donc il ne rentre pas dans la boucle c'est ce que je n'arrive pas a comprendre pourquoi ???
Merci d'avance
u p t sont dans le getopt, mais u d t dans le switch
l'exit après le break n'est jamais exécuté
exit
}
}
je verrai plutot
}
exit
}
ce code n'imprime rien, il faudrait voir la suite du code
l'exit après le break n'est jamais exécuté
exit
}
}
je verrai plutot
}
exit
}
ce code n'imprime rien, il faudrait voir la suite du code
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Que contient argv:
printf("saba\n");
printf("argc=%d\nargv[1]=%s\nargv[2]=%s\n", argc, argv[1], argv[2]);
while ((option = getopt (argc, argv, "u:p:t")) != -1)
ps: argv[0] contient le nom du programme exécuté
printf("saba\n");
printf("argc=%d\nargv[1]=%s\nargv[2]=%s\n", argc, argv[1], argv[2]);
while ((option = getopt (argc, argv, "u:p:t")) != -1)
ps: argv[0] contient le nom du programme exécuté