No, that really isn't what they mean. What MandrewP was saying was that the type cast doesn't change the type of the original variable; it just returns a copy of it's value, changed to the new type. for example, if you have
double a = 17.23;
int b;
b = (int) a;
Then a
itself is still a double
; it hasn't changed at all. Only the value passed to b
was cast to the new type.
As for the actual problem with the int=>char conversion, you are still getting part of it backwards: you need to cast the value to the type it is being copied into, not the type it is already.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a, choice;
char b, choice2;
cout << "Would you like to print the ASCII Table first? (Y/N)"<<endl;
cin >> choice2;
if(choice2=='y' || choice2=='Y')
{
for(int i = 0x21; i <= 0x7E; i += 6)
{
cout << setw(6) << static_cast<char>(i) << " = " << setw(3) << i;
cout << setw(6) << right << static_cast<char>(i + 1) << " = " << setw(3) << i + 1;
cout << setw(6) << right << static_cast<char>(i + 2) << " = " << setw(3) << i + 2;
cout << setw(6) << right << static_cast<char>(i + 3) << " = " << setw(3) << i + 3;
if ((i + 4) < 0x7f)
{
cout << setw(6) << right << static_cast<char>(i + 4) << …