Displaying symbols in C++

Shimergloom

New Member
Reaction score
6
Just need to know how to display symbols in a C++ console application. In particular I need to display °. Tried pasting one in but it shows up as a shaded space in the console.
I know it's a simple thing, but I'm still learning. Help is much appreciated.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
Depending on the OS you're writing your program for, your terminal has to use the correct encoding for any non-ASCII characters and the font should contain the symbol you're trying to render.

In any case, special characters are best written using their hex-code, i.e. 0xA7.
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
How would I go about using the hex-code for °? (the degree symbol)
I think you need to set the output to hexadecimal, although I'm neither sure how to do this or if you need to.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
The same way you'd do it in plain C:
Code:
#include <stdio.h>

int main(int argc, char** argv)
{
        printf("Here we've got a char...: %c\n", 0xBA);
        printf("Here we've got a char...: \xBA\n");

        return 0;
}
 

Shimergloom

New Member
Reaction score
6
The same way you'd do it in plain C:
Code:
#include <stdio.h>

int main(int argc, char** argv)
{
        printf("Here we've got a char...: %c\n", 0xBA);
        printf("Here we've got a char...: \xBA\n");

        return 0;
}
Don't know how to do it in plain C and that makes very little sense to me. ^^;
 

Sintoras

Shaaakaa!
Reaction score
45
I'm guessing you are using iostream. Try learning to use printf. What he did is he took the characters hexadecimal value and used a "variable"(%c). The %c is replaced with the 2nd argument.

Sintoras
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top