The following code is designed for text based files.
[codesyntax lang=”cpp”]
void cmdLFrame::modTravFile(string fileName) { string orec; size_t i; wxTextFile fle(fileName); fle.Open(); size_t irc = fle.GetLineCount(); for (i=0; i < irc; i++) { orec = fle.GetLine(i).ToStdString(); } }
[/codesyntax]
The GetLineCount function returns the total number of lines in the file.
The for loop reads the first line in the file followed by every other line in this ile.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.