On Jan 30, 2008 7:24 PM, Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Ahmed Shabana wrote:
> > #include<stdio.h>
> >
> > int main(int argc, char *argv[])
> > {
> > printf("the value of (int) ++*argv is %d\n",(int)++*argv);
> >
> > // if ( (int) ++*argv > 10 )
> > // return 1 ;
> > // else
> > // return 0 ;
> > }
> >
> > The original program is commented because it's result
> > was 0 only
> > when I comment it and use printf to debug the
> > setiuation the result was unnormal
>
> You are incrementing the _address_ that argv[0] points to by one and
> then casting the address to an integer.
>
> Casting doesn't work like what you seem to expect to want it to do.
> Take a look at the atoi() function. Try: atoi(argv[0]) + 1
>
> (Although, I doubt that will work since the first argument is usually
> the command that initiated the executable. You probably want argv[1]).
Hi
I am not sure but what if he tries the following printf:
printf("the value of (int) ++*argv is %s\n",*(++argv));
This would give the user the value of argv[1], the first parameter
after the command name [program name].
Thanks!! and have a nice day!!
Jaspreet