MIPI_BaseC_WebinarFRTK/12_Lecture12/02_getopt_p17.c
2024-11-13 09:22:28 +03:00

21 lines
767 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int rez=0;
// opterr=0;//Можно отключить вывод сообщений об ошибках, для этого надо где-то в
//программе перед вызовом функции вставить opterr=0
while ( (rez = getopt(argc,argv,"ab:C::d")) != -1)
{
switch (rez)
{
case 'a': printf("found argument \"a\".\n"); break;
case 'b': printf("found argument \"b = %s\".\n",optarg); break;
case 'C': printf("found argument \"C = %s\".\n",optarg); break;
case 'd': printf("found argument \"d\"\n"); break;
case '?': printf("Error found !\n");break;
}
}
}