07-25-05 11:07 PM
hi
i would like to be able to do:
-t 18 -f a1 a2 a3....
i don't know how much parameter there is for f....
are there a way to do that?
the code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
int c;
int timer=0;
int cptTime=0;
char *ifile;
int index;
extern char *optarg;
extern int optind, optopt;
printf("argc: %d\n", argc);
while ((c = getopt(argc, argv, "t:f")) != -1) {
switch(c) {
case 't':
timer=1;
cptTime = atoi(optarg);
break;
case 'f':
ifile = optarg;
break;
}
}
if(timer==1)
while(1==1)
{
}
for (index = optind; index < argc; index++)
printf ("Non-option argument %s\n", argv[index]);
return 0;
}
thanks
[ Post a follow-up to this message ]
|