while((temp=getopt(argc,argv,"a:b:c:d"))!=-1) { switch (temp) { case 'a': is_a=1; a_value=optarg; break; case 'b': is_b=1; b_value=optarg; break; case 'c': is_c=1; c_value=optarg; break; case 'd': is_d=1; break; } }
printf("Option has a:%s with value:%s/n",is_a?"YES":"NO",a_value); printf("Option has b:%s with value:%s/n",is_b?"YES":"NO",b_value); printf("Option has c:%s with value:%s/n",is_c?"YES":"NO",c_value); printf("OPtion has d:%s/n",is_d?"YES":"NO"); i=optind; while(argv[i]) printf(" with arg:%s/n",argv[i++]); exit(0); }