Hello Folks,
I'm currently reading a basic c++ book and tried some example with pointers.
This example works perfect but I don't understand the explanation
In the book stands, that the variable with * (asteriks) points to the value and without the * asteriks to the address of the pointer. But with this fact, my example should print the addresses not the values?
int y[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int x[11] = {9, 8, 0,-1};
void f(int *a, size_t n){
for ( int i = 0; i < n; i++ )
{
Serial.println(a[i]);
}
Serial.println("---------------------");
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
f(x, 10);
f(x, 4);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
printed output
Hello, ESP32!
9
8
0
-1
0
0
0
0
0
0
---------------------
9
8
0
-1
---------------------