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]).
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/