You need to put some code up to see what's going wrong, its likely you're using shared memory and not allocating/accessing correctly for use with independent thread.
Update: Looking at your code, you have
CreateThread()
within a for loop, the for loop will not wait for the thread to be done before moving on, therefore you may end up with multiple threads being created and all accessing the same global variable
c
. This is threads gone wrong... :)
I would suggest going through a CreateThread tutorial (
here's one[
^]) to learn how to use it properly.