I have come across one, hopefully the last, error in my programme that I am unable to fix on my own.
My current problem is the following:
I have written a routine, which is able to create a (pseudo) random combination of 32 characters. It displays the content in a wxTextCtrl called “tc”.
So far so good, but when I have cleared “tc” once, the programme exits with an error. I will attach a screenshot of it and the code at the end of my question.
Any help is appreciated!
Felix
The code:
Code: Select all
void MyFrame::Random() {
int val = 0;
char a1[] = { 'A', 'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,
'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,
'W' ,'X' ,'Y' ,'Z' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f' ,'g' ,'h' ,
'i' ,'j' ,'k' ,'l' ,'m' ,'n' ,'o' ,'p' ,'q' ,'r' ,'s' ,'t' ,
'u' ,'v' ,'w' ,'x' ,'y' ,'z' ,'0' ,'1' ,'2' ,'3' ,'4' ,'5' ,
'6' ,'7' ,'8' ,'9' ,')' ,'=' ,'{' ,'*' ,'>' ,'+', '?',',','@',
'|','-','[','.','/', ']','}','!','"', ':','^', '$','#','%',
';','_', '&','(','<', '`','~'};
srand(time(NULL));
for (int i = 0; i < 32; i++) {
val = (rand() % 76);
str2.push_back(a1[val]);
}
const std::string s1 = str2;
wxString NewSeed = wxString(s1);
tc->SetLabel(NewSeed);
}