What does this pointer-heavy C code do? -


could explain me should 2 following lines do:

s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata; ++((char *)uip_appdata); 

this taken uip code microcontrollers.

s - structure
httpheaderline - http packet presented string
httpheadrlineptr - integer value
uip_appdata - received ethernet packet (string)

if more info needed please let me know.

btw. eclipse reporting error on second line message invalid lvalue in increment i'm trying figure out how solve this.

the intention behind first line grab character pointed uip_appdata:

*(char *)uip_appdata 

casts uip_appdata char*, dereferences it, taking first character.

the second line tries increment uip_appdata. trouble is, not properly, because results of cast cannot incremented "in place".

here 1 way of doing works:

char *tmp = uip_appdata; uip_appdata = ++tmp; 

with code fragment compiler can take care of converting between pointer types in cases when platform requires it.

here demo of concept on ideone.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -