rectangletangle rectangletangle - 1 year ago 205
C++ Question

Superscript in C++ console output

I'd like to have my program output "cm2" (cm squared).

How do make a superscript 2?

Answer Source

As Zan said, it depends what character encoding your standard output supports. If it supports Unicode , you can use the encoding for ²(U+00B2). If it supports the same Unicode encoding for source files and standard output, you can just embed it in the file. For example, my GNU/Linux system uses UTF-8 for both, so this works fine:

#include <iostream>

int main()
    std::cout << "cm²" << std::endl;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download