think in terms of pointers...

they are same :-

p[-1] = *(p - 1)

On Thu, Jan 26, 2012 at 11:15 PM, rahul sharma <rahul23111...@gmail.com>wrote:

> [-1] in end is same as -1 ??????
>
>
> On Thu, Jan 26, 2012 at 11:11 PM, atul anand <atul.87fri...@gmail.com>wrote:
>
>> btw your compiler has sizeof(int)=4;
>> thats why o/p = fg
>>
>> On Thu, Jan 26, 2012 at 11:09 PM, atul anand <atul.87fri...@gmail.com>wrote:
>>
>>> output depends on sizeof(int)....so it may be different if you run on
>>> different compilers.
>>>
>>> considering *sizeof(int) = 2;*
>>>
>>> argv[] is array of pointers.
>>>   (p+=sizeof(int))[-1];
>>> p=p+2 // 2=sizeof(int);
>>>
>>> now p will be pointing at index *argv[2];
>>> then you are doing....
>>>
>>> p=p-1;
>>>
>>> i.e p will point to *argv[1]
>>>
>>> hence output will be
>>> o/p = cd
>>>
>>> On Thu, Jan 26, 2012 at 10:53 PM, rahul sharma 
>>> <rahul23111...@gmail.com>wrote:
>>>
>>>> #include<stdio.h>
>>>> #include<conio.h>
>>>> void fun(char **);
>>>>
>>>> int main()
>>>> {
>>>>     char *argv[]={"ab","cd","de","fg"};
>>>>     fun(argv);
>>>>     getch();
>>>>     return 0;
>>>> }
>>>>
>>>> void fun(char **p)
>>>> {
>>>>      char *t;
>>>>      t=(p+=sizeof(int))[-1];
>>>>      printf("%s\n",t);
>>>> }
>>>>
>>>> o/p: fg
>>>>
>>>> can nyone xplain
>>>>
>>>> the 2nd statement in fun?????
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to