Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #define TRUE 1
- #define FALSE 0
- char giTextValue[8000];
- int main (int argc, char **argv)
- {
- int aflag = FALSE;
- int bflag = FALSE;
- char *cvalue = NULL;
- int index;
- int c;
- opterr = FALSE;
- memset( &giTextValue, 0x20, sizeof( giTextValue ) );
- while ((c = getopt (argc, argv, "abc:")) != -1) {
- switch (c) {
- case 'a':
- aflag = TRUE;
- break;
- case 'b':
- bflag = TRUE;
- break;
- case 'c':
- cvalue = optarg;
- break;
- case '?':
- if (optopt == 'c')
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- else if (isprint (optopt))
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- else
- fprintf (stderr,
- "Unknown option character `\\x%x'.\n",
- optopt);
- return 1;
- default:
- abort ();
- } // END OF SWITCH
- }
- printf ("aflag = %d, bflag = %d, cvalue = %s\n",aflag, bflag, cvalue);
- for (index = optind; index < argc; index++)
- printf ("Non-option argument %s\n", argv[index]);
- // DO SOMETHING FROM PARAMETER
- if( aflag == TRUE )
- giTextValue[5000] = 1;
- else
- giTextValue[5000] = 0;
- if( bflag == TRUE )
- giTextValue[5000] = 2;
- else
- giTextValue[5000] = 0;
- giTextValue[5001] = cvalue;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement