Hello JV,
Here is some pseudo code, and I am sure that
you will find more interesting thing in the way to
finish it.
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<string> fields;
string line = "f1;f2;f3";
StringTokenizer st(line, ";");
// a string tokenizer which separates the line by ";"
while(st.hasNext()) { // test if has next field
string f = st.next(); // get the next field
fields.add(f); // add in list
}
// now, I think you can "directly" access the field.
// but must ensure the index is not out of scope.
cout<< fields[0] ; // fields[0] should be equal "f1"
Post by JVI want to read a comma delimited text file (csv)
How can I have access directly to one of the fields between the ';' ?
Thank you!
Jan