What is the value of random_selector when the program fails? Why do you add one to your random selector value?
What is the value of random_selector when the program fails? Why do you add one to your random selector value?
the value of random selector is 1 every time the program fails, but regardless it should output the wordlist.at(1) right?
And your right, the +1 makes no sense.
Whai is value of wordList.size() ?
Try replace method at( int ) by value( int ). Method value( int ) should work even if int will be out of bounds.http://doc.trolltech.com/4.7/qlist.html#value
Maybe a problem is in different place.
It appears that wordList.size() is = to 1. I just dont know what to do, it does not have to be done my way specifically, I just need to grab one random word from a text file.
If size is 1 then you have only one "word" in wordList. (rand()%1)+1 = 1 but you had a text only under 0 index.
Qt Code:
wordList = dictionaryString.split(" ");To copy to clipboard, switch view to plain text mode
In this line is something wrong. Could you give a wordList_new.txt? Maybe separator which you insert into split is bad.
accordion acorn acrobat actor actress adult advertisement aim air airplane airport terminal, thats the start of it, but there are around 1200 words in it. That exact command works elsewhere in my program.
Opening the file before trying to read it might be helpful.
Fantastic, thank you for your sarcasm laced but efficient and perfect reply.
Bookmarks