passing int array to thread?
hiho@ll
how does this really work: Code:
int array[2]={0}; OUTPUT: 134583088 1078320720 what's this?? i think it's a cast problem but how do i pass a int array to a thread? thx@ll |
I'm guessing your array is a local variable on the stack. Once you leave the function that you declared that variable in, the memory for it goes away, so you are probably using a dangling pointer in your thread function. Try allocating the memory for the array with new/malloc instead.
|
edit: thx, i didn't see your post because i wrote this post beneath while you wrote your reply ;-)
i'll check it tomorrow thx i think the problem was/is that i want to code something like a proxy class the proxy class generates two threads which are listening on 2 sockets using select(); because i want it really full duplex i use 2 threads if i use a static char* buffer both threads get the socket descriptor numbers but i can't really use a static buffer, not? because if there is another object, the threads will overwrite themself, not? hmm *thinking* |
All times are GMT -5. The time now is 10:44 PM. |