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 6549209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:03:55+00:00 2026-05-25T12:03:55+00:00

I noticed a weird problem while using wcout in a console application. After calling

  • 0

I noticed a weird problem while using wcout in a console application.

After calling a certain function, the rest of the wcout calls did not work at all. i.e. the output statements did not appear on the console.

I noticed that in the function, I had used a wide character array which was never assigned.

WCHAR wArray[1024];
wcout<<wArray<<endl;

It was after this call, all the other wcout’s stopped working.

So, I was just curious to know what makes wcout different from cout, and why this problem occured,

  • 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-25T12:03:56+00:00Added an answer on May 25, 2026 at 12:03 pm

    This example invokes undefined behavior.

    operator<<(std::wostream&,const wchar_t*) expects the buffer to be null terminated, and stop printing characters when it reaches the first L'\0' character. If the buffer happens to contain a null character (L'\0'), then the code will run “correctly” (although the output is unpredictable). If it doesn’t, then operator<< will keep reading the memory until it encounters one.

    The presence of a null terminator is not enforced by your example. In comparison, the following would print an unspecified number of characters, most likely junk, but is well defined:

    WCHAR wArray[1024];
    wArray[1023] = L'\0';
    wcout << wArray << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have noticed a weird error when calling ToLower() on certain strings. The input
After testing a while with the Cmd.cmd framework in python, I noticed a problem
I have this really weird problem with my MySQL table. After some time a
I've been working for a while on image processing and I've noticed weird things.
While polishing off an installer of mine, I noticed something weird in the Programs
I noticed a good while back that Wikipedia links to a Javascript implementation of
I am getting weird problem, the crash happens at random times, for example i
I'm testing an android application with a long running service. I'm using Eclipse and
Hi I'm experiencing a super weird problem. Whenever I post links to my website
I'm not quite sure I understand what Html.RenderAction() does. I've just noticed one weird

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.