天天看點

指針自增學習

晚上在 QQ 群裡看群友南說數組指針自增後不會。

指針自增學習

#include <stdio.h>
unsigned char a[2] = {0x15, 0x23};

void sendData(unsigned char *DataR11)
{
    unsigned char DataR1,DataR2,DataR3;
    
    DataR1 = *DataR11;
    DataR2 = *DataR11++;
    DataR3 = *DataR11;
    // 輸出 0x15
    printf("%x\n", DataR1); 
    // 輸出 0x15,因為自增是先用後自增。
    printf("%x\n", DataR2);
    // 輸出 0x23,說明上一步指針是有自增的。
    printf("%x\n", DataR3);
}
int main(void)
{
    sendData(a);
}