[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: const char* typedefs
- From: Paige DePol <lual@...>
- Date: Wed, 7 Feb 2018 21:13:22 -0600
Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Paige DePol once stated:
>>>> I don't know what you mean by "the whole 2[pa] bit" though, can you explain?
>>>
>>> #include <stdio.h>
>>>
>>> char *a[] = { "zero" , "one" , "two" , "three" };
>>>
>>> int main(void)
>>> {
>>> puts( a[0] );
>>> puts( 1[a] );
>>>
>>> putchar( 2[ 3[a] ] ); putchar('\n');
>>> putchar( 2["0123"] ); putchar('\n');
>>>
>>> return 0;
>>> }
>>>
>>> Valid. And it runs without error.
>>
>> What the heck is this voodoo magic? I have never seen this syntax before.
>
> It comes because array syntax is "syntactic surgar."
LOL. Right, which is what I was saying about the array vs pointer stuff! :)
> So let's take a[1]...
The StackOverflow article pretty much stated the same thing. I guess I just
never really thought of the array indexing symbols as "operators" per se.
Of course, they are and that is why this little trick works... but still
it is a pretty odd syntax to be able to use. Definitely a good trick you
can use on those who don't know about it!
~Paige
[1] I think you're addicted to footnotes! ;)
- References:
- const char* typedefs, Paige DePol
- Re: const char* typedefs, Forrest Christian (List Account)
- Re: const char* typedefs, Dirk Laurie
- Re: const char* typedefs, Paige DePol
- Re: const char* typedefs, Sean Conner
- Re: const char* typedefs, Paige DePol
- Re: const char* typedefs, Sean Conner
- Re: const char* typedefs, Paige DePol
- Re: const char* typedefs, Sean Conner
- Re: const char* typedefs, Paige DePol
- Re: const char* typedefs, Sean Conner