This is how you get it printed to the terminal.
cout << "Current thread ID: " << this_thread::get_id() << endl;
Of course when there are multiple threads the output becomes interleaved and impossible to figure out. So I wanted to log each thread’s output to its own file. But I need the thread ID to give a name to the file to send to fopen(). How to use iostream to save thread ID to a string?
Use std::stringstream