Get the App
SLTechnology News&Howtos  ›  Network Security  › 

C language pointers to array elements

Shulou Source: shulou.com Published: 2022-06-01 03:06:14 10月03日 Update

Pointers and operation rules pointing to array elements

A pointer to an array element is essentially the same as a pointer to a variable. Since each element in the array can be directly counted as a variable, the pointer to the array element, that is, the pointer to the variable.

Pointers to array elements are not difficult, but are commonly used. It will be more straightforward when we use the program to explain it.

Unsigned char number [10] = {0,1,2,3,4,5,6,7,8,9}; unsigned char * p

If we write p = & number [0]; then the pointer p points to element 0 of number, which assigns the address of number [0] to p, similarly, if we write p = & number [1]; p points to element 1 of the array number. P = & number [x]; where the size of x is 0,9, which indicates that p points to the x element of the array number. The pointer itself can also stop several complex operations, which are most frequently used in terms of pointers to array elements.

Analogy operation. The premise of comparison is that two pointers point to objects of the same type, such as two pointer variables p and Q, which point to an array of the same data type, then they can stop, > =, 0) {/ / when the data is to be sent, continue to send subsequent bytes SBUF = * ptrTxd; / / retrieve the data pointed to by the pointer cntTxd--; / / send counter plus ptrTxd++; / / send pointer increment}

Tags: Arrays pointers elements points suffixes serial ports data programs operations variables addresses that is bytes edict people representatives tags two functions time division Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Apple NVidia Xiaomi