pointer-arithmetic
uintptr_t portable alternative
I want to perform check for memory alignment of some type T. The straightforward way to do this is if (((uintptr_t)&var & __alignof(T) - 1) == 0) ...[详细]
2023-02-11 05:52 分类:问答Is apparent NULL pointer dereference in C actually pointer arithmetic?
I\'ve got this pieceof code. It appears to dereference a null pointer here, but then bitwise-ANDs the result with unsigned int. I really don\'t understand the whole 开发者_如何学Gopart. What is it int[详细]
2023-02-01 00:15 分类:问答Problem with strchr
I can\'t get why the following bit of C code doesn\'t work: int obtainStringLength(char* str, char c1, char c2) {[详细]
2023-01-29 22:05 分类:问答population structure by memory address in C
i am having a problem while populating the structure members with address reference but when it is done using the member it self then its fine.[详细]
2023-01-27 09:10 分类:问答The new IntPtr.Add method - am I missing the point of the int?
Starting from FW 4.0, the IntPtr structure has the Add method: public static IntPtr Add( IntPtr pointer,[详细]
2023-01-26 22:57 分类:问答void * assignment problem
I want to take some fields from packet struct using pointer arithmetic.But what is wrong with the code below ?[详细]
2023-01-18 22:23 分类:问答Order of operations for dereference and bracket-ref in C
If I do *ptr[x], is that equivalent to *(ptr[x]), or开发者_如何学Python (*ptr)[x]?*(ptr[x]) See the Wikipedia operator precedence table, or, for a more detailed table, this C/C++ specific table.In C,[详细]
2023-01-12 15:32 分类:问答Pointer arithmetic for void pointer in C
When a pointer to a particular type (say int, char, float, ..) is incremented, its value is increased by the size of that data type. If a void pointer which points to data of size x is incremented, ho[详细]
2023-01-12 12:16 分类:问答Substracting pointers: Where does this missing level of indirection come from?
I\'m having trouble understanding the behavior of the MS VC compiler on this one. This line compiles fine, but the result I get is not 开发者_如何转开发what I\'d expect at all:[详细]
2023-01-08 01:34 分类:问答Pointer arithmetic and arrays: what's really legal?
Consider the following statements: int*pFarr, *pVarr; intfarr[3] = {11,22,33}; intvarr[3] = {7,8,9}; pFarr = &(farr[0]);[详细]
2022-12-22 11:51 分类:问答