I wrote some C++ code to show ASCII characters on a console which I found in a book i was reading. The code looked like this:
#include <iostream>
using namespace std;
int main()
{
for (unsigned char i = 32; i<128; i++)
cout << i;
int response;
cin >> response;
return 0;
}
When I take away the unsigned
keyword and use signed
instead, the results become infinite and the PC beeps until I shut off the executable file. But when I use an int i
variable instead I don't need to unsign the variable. Why is that?