Sometimes a function is needed to load the contents of a text file into a wxArrayString. The following code snippet accomplishes the desired task.
[codesyntax lang=”cpp”]
void srcColFrame::loadSC(string fs, wxArrayString sc, int ix) { ifstream ips; ips.open(fs); string line; while (getline (ips, line)) { fsp[ix].coll.Add(line); //sc.Add(line); } }
[/codesyntax]
The input file is processed line by line while simultaneously adding the line to the associated collection.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.