While Loop Does Not Initialize [Solved]

Posts 18 of 8 · Page 1 of 1
While Loop Does Not Initialize [Solved]
The while loop in the AutoClick function does not initialize.

Here is my function to create thread.
Code:
void cBase::ThreadCreate(bool MenuVal,HANDLE hName,LPTHREAD_START_ROUTINE tName,bool& tBool,bool& hBool)
Using the Function Above:
Code:
HANDLE hNames[2];
bool hFlags[2]= {true, true};
bool tFlags[2];

int n = 0;
int h = 0;
int t = 0;
Base.ThreadCreate( hack1, hNames[n++], (LPTHREAD_START_ROUTINE)AutoClick,   tFlags[h++], hFlags[t++] );
Auto Click Function
Code:
void AutoClick()
{
        MessageBoxA(0, "test1", "title", MB_ICONEXCLAMATION | MB_OK); //this works

	while( tFlags[1] )
	{
        MessageBoxA(0, "test2", "title", MB_ICONEXCLAMATION | MB_OK); //this does not activiate

		Sleep(1000);
	}
}
Because you haven't initialized tFlags array.
Quote Originally Posted by Hassan View Post
Because you haven't initialized tFlags array.
Yes I have.

Base.ThreadCreate( hack1, hNames[n++], (LPTHREAD_START_ROUTINE)AutoClick, tFlags[h++], hFlags[t++] );

and in the CreateThread function it maks tFlags[1] = true.
Quote Originally Posted by Braco22 View Post
Yes I have.

Base.ThreadCreate( hack1, hNames[n++], (LPTHREAD_START_ROUTINE)AutoClick, tFlags[h++], hFlags[t++] );

and in the CreateThread function it maks tFlags[1] = true.
What ? How does that initializes it ? [] operator is used to access or set a particular item. In this case, you are just accessing the 0th element of the array. h++ is post increment, not pre increment, so the value changes to 1 after this statement. /FP
Quote Originally Posted by Hassan View Post


What ? How does that initializes it ? [] operator is used to access or set a particular item. In this case, you are just accessing the 0th element of the array. h++ is post increment, not pre increment, so the value changes to 1 after this statement. /FP

I see so i should put h = 1?

yup this did the trick. pardon for my lack of understanding of C++..
No Problem. So is it safe for me to mark the thread solved ?
Yes thank you Hassan.
NP. /Marked Solved.
Posts 18 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?