Read Text File Line

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);
    size_t irc = fle.GetLineCount();

    for (i=0; i < irc; i++)
        orec = fle.GetLine(i).ToStdString();



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.

Leave a Reply

Your email address will not be published. Required fields are marked *