File To String Array

The following code will place the contents of a text file into a string array.

[codesyntax lang=”cpp”]

void grailsGenFrame::OnmenOpt1Selected(wxCommandEvent& event)
{
    wxArrayString str;
    str.Clear();
    wxTextFile inf;
    wxString fbuf;
    inf.Open("/home/archman/workspace/grails/grailsSkel/build.gradle");
    for ( fbuf = inf.GetFirstLine(); !inf.Eof(); fbuf = inf.GetNextLine() )
    {
        str.Add(fbuf);
    }
}

[/codesyntax]

 

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 *