Open WXQ6989 opened 2 years ago
for (
TinyGPSCustom *p = customCandidates; // 1
p != NULL && strcmp(p->sentenceName, customCandidates->sentenceName) == 0; // 2
p = p->next) { // 3
p->commit();
}
I reformatted your piece of code a bit and added the comments 1
, 2,
and 3
.
In a for loop, you have 3 parts, separated by a semicolon (;
)
Typical for loop:
for (int i = 0; i < 10; ++i) {
}
Back to your code:
customCandidates
is a list of pointers, so you get the first element of it.sentenceName
of the element p
with the first element, to see if it is the same.In short, it looks like this checks the list of candidates to see if the strings match and calls commit()
on those.
N.B. this for loop stops as soon as a string is found that does not match, so the order is important.
I am new in C++ here, In all this code, how to divide and parse the required time or location information?
and how to understand the following sentence:
for (TinyGPSCustom *p = customCandidates; p != NULL && strcmp(p->sentenceName, customCandidates->sentenceName) == 0; p = p->next) p->commit();
Thank you very much