Can someone explain/confirm me meaning of below lines?
bool instring{false};
- this mean that false is the initial value of this variable, yes?for (const char* p = mystart; *p; p++)
- here pointer*p
at second parameter offor
means that this loop exist to the moment that this pointer exist, yes?string(mystart,p-mystart)
- I can't find this string usage in c++ reference, I know result of it is difference between this parameters, but don't understand how this happen.
This lines are from code below(original code from another SO question):
string line;
while (std::getline(cin, line)) { // read full line
const char *mystart=line.c_str(); // prepare to parse the line - start is position of begin of field
bool instring{false};
for (const char* p=mystart; *p; p++) { // iterate through the string
if (*p=='"') // toggle flag if we're btw double quote
instring = !instring;
else if (*p==',' && !instring) { // if comma OUTSIDE double quote
csvColumn.push_back(string(mystart,p-mystart)); // keep the field
mystart=p+1; // and start parsing next one
}
}
csvColumn.push_back(string(mystart)); // last field delimited by end of line instead of comma
}