Change const char *arrays[10];
to string arrays[10];
and arrays[k] = line.c_str();
to arrays[k] = line;
and (void*) arrays[k]
to (void*)arrays[k].c_str()
.
The problem is that once the line
changes to the next value previous arrays[k]
points to a meaningless piece of memory. You have to save the value of line
in order to enable the thread to access it.