Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
lehrkraefte:blc:informatik:ffprg2-2020:esp32-arrays [2020/08/21 09:54] Ivo Blöchliger |
lehrkraefte:blc:informatik:ffprg2-2020:esp32-arrays [2020/08/21 15:47] (current) Ivo Blöchliger |
||
---|---|---|---|
Line 5: | Line 5: | ||
// statisch mit Initialisierung (Grösse automatisch) | // statisch mit Initialisierung (Grösse automatisch) | ||
int ledPins[] = {18, | int ledPins[] = {18, | ||
+ | int numLeds = sizeof(ledPins)/ | ||
int counters[5]; | int counters[5]; | ||
- | int data[]; // Noch keine Elemente | + | int *mydata; // Noch keine Elemente, nur Platz für einen Pointer (Speicheradresse) |
+ | int *moredata; | ||
void setup() { | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | delay(200); | ||
+ | | ||
+ | Serial.printf(" | ||
+ | counters[0] = 3; | ||
+ | Serial.printf(" | ||
+ | | ||
+ | mydata = new int[7]; | ||
+ | |||
+ | moredata = new int[10]; | ||
+ | |||
+ | moredata[0] = 42; | ||
+ | |||
+ | // Ein bisschen Hacking: Pointer-Arithmetik | ||
+ | Serial.printf(" | ||
+ | Serial.printf(" | ||
+ | | ||
+ | mydata[11]=23; | ||
+ | | ||
+ | Serial.printf(" | ||
+ | |||
+ | delete[] mydata; | ||
+ | delete[] moredata; | ||
+ | | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
} | } | ||
</ | </ | ||