H
Harris Kosmidis
Hello, I'm writing a program and I'm stuck in something silly, which I
thought it worked for some time.
I want to parse the arguments.
I want to run it like:
../prog image.jpg [-t] [-r floatnum] [-n floatnum]
Here's the code:
char fname[100];
double f_radius=0.8,f_n=0.8;
while (--argc) {
++argv;
if (*argv[0] != '-')
strncpy (fname, argv[0], 99);
else
++argv[0];
switch (*argv[0]) {
case 'd': debug = 1; break;
case 'r': ++argv; --argc;f_radius=atof(argv[0]);break;
case 'n': ++argv; --argc;f_n=atof(argv[0]);break;
case 't': ++argv; --argc;train=1;break;
}
}
If I do:
../a.out testimage.jpg -t -r 0.09 -n 0.09
it goes OK.
When I do:
../a.out testimage.jpg -r 0.09 -n 0.09 [omitting -t that is]
I get
main.c main 102 unable to open image `0.09': No such file or directory
(error that ImageMagick can't open the image file I provided).
What's wrong? Can somebody help me out?
thanks
thought it worked for some time.
I want to parse the arguments.
I want to run it like:
../prog image.jpg [-t] [-r floatnum] [-n floatnum]
Here's the code:
char fname[100];
double f_radius=0.8,f_n=0.8;
while (--argc) {
++argv;
if (*argv[0] != '-')
strncpy (fname, argv[0], 99);
else
++argv[0];
switch (*argv[0]) {
case 'd': debug = 1; break;
case 'r': ++argv; --argc;f_radius=atof(argv[0]);break;
case 'n': ++argv; --argc;f_n=atof(argv[0]);break;
case 't': ++argv; --argc;train=1;break;
}
}
If I do:
../a.out testimage.jpg -t -r 0.09 -n 0.09
it goes OK.
When I do:
../a.out testimage.jpg -r 0.09 -n 0.09 [omitting -t that is]
I get
main.c main 102 unable to open image `0.09': No such file or directory
(error that ImageMagick can't open the image file I provided).
What's wrong? Can somebody help me out?
thanks