I'm newer in C/C++, I really confuse about a function that executes complex operation. I just want to know how it works ? What does function mean ?
void writetoXX(unsigned int **src, unsigned int reg_offset, unsigned int reg_data){
*(*src)++ = reg_offset;
*(*src)++ = reg_data;
}
Any idea ??
Update my understanding:
void writetoXX(unsigned int **src, unsigned int reg_offset, unsigned int reg_data) {
*(*src)++ = reg_offset;
*(*src)++ = reg_data;
}
int main() {
int a[10] = { 0 };
int *p = a;
printf("Before !!\n");
for(int i=0;i<10;i++)
printf("%d ", a[i]);
writetoXX(&p, 20, 30);
printf("After !!! \n");
for (int i = 0; i<10; i++)
printf("%d ", a[i]);
getchar();
return 0;
}
After run this program, I see that the function writetoXX change value arr[0][0] and arr[0][1] to 20 and 30. It means that the function is used for write data to 2 consecutive blocks.
And output is below:
Before !!
0 0 0 0 0 0 0 0 0 0
After !!
20 30 0 0 0 0 0 0 0 0