Explaination of a typecast: It basically makes one variable type into another. So, basically I can take an integer variable and make it a character. The ANSII chart we are going to make is gonna be centered around the one on this site. If you are looking at this, I am assuming you know the basics of C++, so I wont explain the main function. For an explanation of a for loop, look at my tutorial. I am only going to explain the typecast.
The code:
#include <iostream>
using namespace std;
int main(void) {
for(int x=0;x <=127;x++){
cout << x << " = " << (char)x << endl;
}
}
Explanation:
cout << x << " = " << (char)x << endl;Basically, I declared variable x as an integer. By placing (char) in front of it, I typecasted it into a character, meaning the value of x was changed into its ANSII value.
I know this wasn't that great, but it has been a while since I've written a tutorial, so meh... Any questions you may have, feel free to ask. I am always willing to help.


Sign In
Create Account


Back to top









