I'm gonna describe my problem the best I can. Let's say my program reads a word (a line) from a text file. The word is 4 characters long. If the next word I read (to the same variable) is shorter (say 3 characters) I still get the fourth character left on the end from the last word. And the same goes if the new word is 2 characters but then I get the two last characters from the word with 4 characters. Example:
Word 1 = がっこう (4 characters)
Word 2 = いえ (2 characters)
So if my program first reads がっこう from the text file and then the program reads いえ from the same text file the new word I get isn't いえ but instead I get いえこう
Here is the function for reading lines/words from the text file:
Code: Select all
wxString getstring(int k)
{
wxTextFile file;
file.Open(wxT("text.txt"));
wxString line = file.GetLine(k);
return(line);
}
Code: Select all
void Window::OnNext(wxCommandEvent & WXUNUSED(event))
{
k = k + 4;
wxStaticText *st = new wxStaticText(panel, wxID_ANY, getstring(k));
wxTextFile file;
file.Open(wxT("text.txt"));
int nlines = file.GetLineCount();
if(k == nlines - 2){
k = -2;
}
}
Thank you in advance!
/DT