# Include <ctype.h> # Include # Include <stdlib.h> # Include int main (int argc, char ** argv) { aflag int = 0; bFlag int = 0; char * cValue = NULL; int index; int c; opterr = 0; while ((c = getopt (argc, argv, "abc:"!)) = -1) interruptor (C) { case 'a': aflag = 1; break; case 'b': bFlag = 1; break; case 'c': cValue = optarg; break; case '?': if (optopt == 'c') fprintf (stderr, "La opción -% c requiere un argumento \ n"., optopt); else if (isprint (optopt)) fprintf (stderr, "Opción desconocida` -% c '\ n "., optopt); más fprintf (stderr, "Opción desconocida carácter '\ \ x% x'. \ N", optopt); return 1; por defecto: abort (); } printf ("aflag% = d, bFlag% = d, cValue =% s \ n", aflag, bFlag, cValue); para (index = optind; Índice general <argc, índice + +) printf ("Non-opción argumento% s \ n", argv [indice]); return 0; } |