-
Notifications
You must be signed in to change notification settings - Fork 20
/
PointersQueue.ino
executable file
·53 lines (41 loc) · 1002 Bytes
/
PointersQueue.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Pointers Queue
Pointers queue demonstration
This example code is in the public domain.
created 25 May 2018
modified 04 November 2020
by SMFSW
*/
#include <cppQueue.h>
const char * str[3] = {
">>> This example demonstrates how to strip quotes",
">>> from strings using a queue of pointers",
">>> to access methods from the string class."
};
cppQueue q(sizeof(String *), 3, FIFO); // Instantiate queue
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
}
// the loop function runs over and over again forever
void loop() {
String strings[3];
String * pStr;
Serial.println("Original text:");
for (unsigned int i = 0 ; i < 3 ; i++)
{
strings[i] = str[i];
pStr = &strings[i];
q.push(&pStr);
Serial.println(strings[i]);
}
Serial.println("");
Serial.println("Processed text:");
for (unsigned int i = 0 ; i < 3 ; i++)
{
q.pop(&pStr);
pStr->remove(0, 4);
Serial.println(*pStr);
}
while(1);
}