Cout of unsigned char

I'm using Visual Studio 2019: why does this command do nothing?

std::cout << unsigned char(133);

It literally gets skipped by my compiler (I verified it using step-by-step debug):
I expected a print of "à".
Every output before the next command is ignored, but not the previous ones. (std::cout << "12" << unsigned char(133) << "34"; prints "12")

I've also tried to change it to these:
1
2
3
std::cout << unsigned char(133) << std::flush;
std::cout << (unsigned char)(133);
std::cout << char(-123);

but the result is the same.

I remember that it worked before, and some of my programs that use this command have misteriously stopped working... In a blank new project same result!

I thought that it my new custom keyboard layout could be the cause, but disabling it does not change so much.

On other online compilers it works properly, so may it be a bug of Visual Studio 2019?
Hello Foxel,

I ran this through my VS2017:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <iomanip>

int main()
{
	std::cout << unsigned char(133) << '\n';
	std::cout << static_cast<unsigned char>(133) << '\n';
	std::cout << "12 " << unsigned char(133) << " 34";

	// A fair C++ replacement for "system("pause")". Or a way to pause the program.
	// The next line may not be needed. If you have to press enter to see the prompt it is not needed.
	//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  // <--- Requires header file <limits>.
	std::cout << "\n\n Press Enter to continue: ";
	std::cin.get();

	return 0;	
}

And it produced the output of:
                                     // <--- Intentional blank line.
 à
 à
 12 à 34

 Press Enter to continue:



Since I could not duplicate your problem I wonder if there is something else in the whole program that is wrong or otherwise causing a problem.

Most times it is best to post the whole program or at least enough to show the problem.

Andy
Topic archived. No new replies allowed.