c++ - using global array inside threads -
what want is, if data in array buff inside thread changes, global variable global_buff data must change
#include <process.h> ......... char global_buff_1[50]; char global_buff_2[50]; void thread (int x) { char buff[50] = {0}; if (x == 0) buff = global_buff_1; //this need, how can equal 2 array correctly. want if buff array data changing global_buff changing. else buff = global_buff_2; ............. //do thing ............. } int main(int argc, char* argv []) { ................... int y = 0; _beginthread((void(*)(void*))thread, 0, (void*)y); ..................... } any helping!
void thread (int x) { char* buff = 0; // change here pointer if (x == 0) buff = global_buff_1; // new these assignments work. , when changing buff else // global_buff_1 , global_buff_2 change depending on buff = global_buff_2; // assignment done here ............. //do thing ............. }
Comments
Post a Comment