Ok I feel like this may be a dumb question, but I'm putting it out there anyway. It's been a while since I've worked with C++.
What characters does C++ print for negative values of char?
Positive values seem to follow ASCII, but ASCII is only 128 characters. So where are the others from?

#include<iostream>

using namespace std;

int main() {

   char myChar = 127;
   
   while(myChar > -128) {
      cout << static_cast<int>(myChar) << " " << myChar << endl;
      myChar--;
   }
   cout << static_cast<int>(myChar) << " " << myChar << endl;

   return 0;
}

>Positive values seem to follow ASCII, but ASCII is only 128 characters. So where are the others from?
It really depends on the character set your system is using, but probably Unicode or some form of extended ASCII.

Edited 6 Years Ago by Narue: n/a

Thanks Narue. I guess it must be extended ASCII (didn't know that exists) because if I set char > 127 or < -128 the program does funny things.

This question has already been answered. Start a new discussion instead.