Created
August 15, 2018 07:32
-
-
Save levex/5168971a7772444967df746431ea384a to your computer and use it in GitHub Desktop.
Processing arguments in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *s; | |
while (--argc > 0 && (*++argv)[0] == '-') | |
for(s = argv[0]+1; *s != '\0'; s++) | |
switch(*s) { | |
case 'x': | |
/* Set appropriate flags for 'x' option */ | |
break; | |
case 'n': | |
/* Set appropriate flags for 'n' option */ | |
break; | |
default: | |
printf("Illegal option %c\n", *s); | |
argc = 0; | |
break; | |
} | |
if( argc != 1) | |
printf("Usage: find -x -n pattern\n"); | |
else | |
/* Main program logic goes here */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment