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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.