Sunday, 15 July 2012

c++ - (char *) (msg +1) where does this +1 takes us to? -


I'm seeing a code in which I have a statement (char *) (emsg + 1) given,

I think that (char *) emsg might be a string, but what does + 1 do ?

EMSG is a type of pointer (like int < / Code>). The indicator increases with EMSG + 1 1, i.e. indicates the initial address + sizeof (int) . Then, (four *) (EMSG + 1) is an artist, i.e. the end result is applied to a four * pointer, so you get a pointer-to initial address + sizeof (int) .

In general, there are hints for four * characters, that is, zero ended string like C , but this is not always the case. When you are an underlying type indicator based on the maximum number of machines on the basis of char * , you often convert an indicator to char * The small unit of memory "remove" wants a byte ( char).


No comments:

Post a Comment