0

I'm trying to uppercase a reference to output in the console however it doesn't seem to work and just outputs the normal reference where all the char are lower case. Ive tried "toUpper()" and it doesnt let me as there are ints too. Any idea how to uppercase the varInt reference?

#include <Windows.h>
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    int varInt(123456);
    cout << "varInt       " << uppercase << &varInt << " = " << varInt << endl;}

output: varInt 0x54be5ff85c = 123456

I want the chars after 0x to be uppercase so its easier to read.

  • I'm not sure what you mean by "uppercase a reference". Could you edit the question to include actual output and expected output? – Nathan Pierson Feb 24 '23 at 14:46
  • 2
    The printing format for pointers is not well-defined and is intended for debugging. If you want a specific format, cast to `uintptr_t` and print that instead in any format you want. – Silvio Mayolo Feb 24 '23 at 14:49
  • That's not a reference, it's a pointer. The ampersand, `&`, has several meanings. – molbdnilo Feb 24 '23 at 14:49

1 Answers1

0

This is documented, see cppreference.com - std::uppercase:

Enables the use of uppercase characters in floating-point and hexadecimal integer output.

This doesn't apply to pointer output, e.g. &varInt.

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198