Quote:
Shouldn't the example check while (curPos > 0) instead of resToken != "" ? What happens if you have a CSV file that has
value,value,,
value,value,value
You will never parse the last 3 values.
Consecutive delimeters will be collapsed, so in your example it would correctly return 5 values e.g.:
Code:
CAtlString Input = "value1,value2,,\nvalue3,value4,value5\n";
CAtlString tok;
int pos = 0;
while( (tok=input.Tokenize(", \n", pos)) != "" )
printf("tok=%s\n", tok );
Output:
tok=value1
tok=value2
tok=value3
tok=value4
tok=value5