|
-
Mar 3rd, 2001, 05:03 PM
#1
Thread Starter
Frenzied Member
I keep getting pretty bad errors on this...like protection faults.
here is the code in my button:
PHP Code:
int thenumber;
char * pc;
itoa(thenumber, pc, thenumber);
srand(time(NULL));
num1 = 1 + rand() % 3;
num2 = 1 + rand() % 3;
num3 = 1 + rand() % 3;
SendMessage(ghWnd_Slot1, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num1, pc, 10));
SendMessage(ghWnd_Slot2, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num2, pc, 10));
SendMessage(ghWnd_Slot3, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) itoa(num3, pc, 10));
-
Mar 3rd, 2001, 05:08 PM
#2
Monday Morning Lunatic
It's the way you used itoa. You need to have a buffer of a sufficient size - I normally use 40 characters:
Code:
char buf[40];
int x = 5;
itoa(x, buf, 10); // 10 is the radix (number base)
Also, don't use LPCTSTR unless you're willing to use Unicode . Just use plain LPCSTR. And since casting just converts it around you don't need it and can stay with LPARAM.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 3rd, 2001, 05:51 PM
#3
Thread Starter
Frenzied Member
-
Mar 3rd, 2001, 05:56 PM
#4
Thread Starter
Frenzied Member
Oh by the way, I meant to ask you something. I noticed that it doesn't change the numbers sometimes, but the cash does change (I think you'll have to download the attachment to know what I'm talking about)....its in the button named ghWnd_Pull
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|