Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### getargs demo
- #include <unistd.h>
- #include <stdio.h>
- int main (int argc, char *argv[])
- {
- int ch;
- int avgSec = 0;
- if (argc == 1) {
- printf ("You specified no parameters.\n");
- }
- while ((ch = getopt(argc, argv, "a:fhm:z")) != -1) {
- switch (ch) {
- case 'a':
- printf ("You specified the -a option ");
- printf ("with the parameter \"%s\".\n", optarg);
- avgSec = atoi(optarg);
- printf ("Will run for %d seconds and calculate avg fps.\n", avgSec);
- break;
- case 'f':
- printf ("You specified the -f option.\n");
- printf ("Starting in fullscreen mode.\n");
- break;
- case 'h':
- printf ("You specified the -h option.\n");
- printf ("Usage info goes here.\n");
- break;
- case 'm':
- printf ("You specified the -m option ");
- printf ("with the parameter \"%s\".\n", optarg);
- //printf ("Starting in mode %d.\n", atoi(optarg));
- break;
- case 'z':
- printf ("You specified the -z option.\n");
- printf ("Starting in zoomed (windowed) mode.\n");
- break;
- default:
- printf ("You specified a parameter I don't know about.\n");
- break;
- }
- }
- argc -= optind;
- argv += optind;
- return avgSec;
- }
Add Comment
Please, Sign In to add comment