Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3335816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:03:43+00:00 2026-05-18T00:03:43+00:00

I tried to redirect standart output (cout) to a file, for debugging purposes std::ofstream

  • 0

I tried to redirect standart output (cout) to a file, for debugging purposes

std::ofstream traceFile;
traceFile.open("c:/path/file.txt");
std::streambuf* fileBuff = traceFile.rdbuf();

std::cout.rdbuf(fileBuff);

std::cout << std::unitbuff;

std::cout << "disk is written\n";

But calling cout from a new thread make the code stuck on a mutex. (xmtx.c 39: _Mtxlock()).

Have you got an idea, how i could solve it?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:03:43+00:00Added an answer on May 18, 2026 at 12:03 am

    This example works fine for me, whilst your test case doesn’t. On my machine your code seemed to double free the streambuf from the file, whereas this example swaps it back before the destructors are called.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried putting this code Redirect 301 /pagename http://www.example.com/pagename.html in my .htaccess file; but
I am trying to redirect to a specific path based on HTTP_HOST or SERVER_NAME
I tried to redirect the users who directly enter the URL of the home
i tried to configure apache's reverse proxy on a server to redirect the requests
I just tried to add the following htaccess rules to redirect all https urls
i try to redirect url's like: example.com/video/1640/video-name to example.com/video/1640/video-name/ i've tried with: RewriteRule ^video/([^/]*)/([^/]*)/$
I'm no .htaccess expert, but I've tried a few different things to redirect a
I want to use response.redirect to open page in new window or tab. I
What is the equivalent code of Response.Redirect(~/Account/Login.aspx); in javascript? I tried : window.location=~/Account/Login.aspx but
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.