<div>I&#39;m working on a authentication module and I need to produce a string without any inherent fixed structure, so I would just using ngx_sprintf and pointer arithmetic. However something insidious is going on during compilation. I have played arround with u_char * as well as char *&#39;s. The gdb debug sessions goes as follows:</div>
<div><br></div><div>-----------------------------------------------------------------------------------------------------------------------</div><div>680<span class="Apple-tab-span" style="white-space:pre">        </span>    char * buf = (char *) ngx_palloc( r-&gt;pool, sz);</div>
<div>(gdb) n</div><div>681<span class="Apple-tab-span" style="white-space:pre">        </span>    if ( buf  == NULL)</div><div>(gdb) n</div><div>687<span class="Apple-tab-span" style="white-space:pre">        </span>    if( parameter_count &gt; 0) {</div>
<div>(gdb) n</div><div>688<span class="Apple-tab-span" style="white-space:pre">        </span>        buf = (char *) ngx_sprintf((u_char *)buf,&quot;%V?&quot;, &amp; alcf-&gt;redirect_url);</div><div>(gdb) n</div><div>690<span class="Apple-tab-span" style="white-space:pre">        </span>        buf++; buf++;// buf++; buf++; buf++;</div>
<div>(gdb) p buf</div><div>$1 = 0x6d2de0 &quot;lala?&quot;</div><div>(gdb) n</div><div>698<span class="Apple-tab-span" style="white-space:pre">        </span>        if( parameters[i]-&gt;len != 0) {</div><div>(gdb) p buf</div><div>
$2 = 0x6d2de7 &quot;&quot;</div><div>-----------------------------------------------------------------------------------------------------------------------</div><div><br></div><div>I should see 2 = 0x6d2de2 &quot;la?&quot;  as output</div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div>I have only incremented the char pointer twice, yet the pointer moves forward 7 bytes (and when I do a +=5 it moves forward 10 bytes). I am hoping someone can tell me what is going on here, as t his has completely flabbergasted me.</div>
<div><br></div><div>Regards</div><div><br></div><div>Hassan</div>