:: Re: [DNG] Making sense of C pointer…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Hendrik Boom
日付:  
To: dng
題目: Re: [DNG] Making sense of C pointer syntax.
On Thu, Mar 31, 2016 at 08:38:26AM -0300, Emiliano Marini wrote:
> +1
>
> Besides, * and [] are interchangeable. You can define a string as an array
> and use it later as a pointer:
>
> char s[] = "hola";
> char x = s[1];     // Here x = 'o'
> char y = *(s+2);   // Here y = 'l'

>
> And vice versa:
>
> char *s = "hola";
> char x = s[0];     // Here x = 'h'
> char y = *(s+3);   // Here y = 'a'


Bit sizeof(s) will not be the sae iin the two versions.

-- hendrik