I am currently writing a c++ program that uses threads to write strings to a file. I am using ofstream to write these strings, and I noticed that only one of the threads has acc
Having multiple threads to write to the same file can lead to some serious troubles. You can try synchronizing the process of writing, by using critical section, for example(using OpenMP):
#pragma omp critical [(name)]
{
write_to_file
}
or using WinApi: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686908(v=vs.85).aspx