Well, manofsteel gave you the correct syntax for using static_cast.
If you need more examples of what it does, try this
Code:
#include <iostream>
int main()
{
char suit[4] = {3,4,5,6};
int i[4] = {3, 4, 5, 6};
char isuit;
char jsuit;
isuit = static_cast<char>(i[0]);
jsuit = (char)i[0];
std::cout << "Using char array: ";
std::cout << "suit[0] = " << suit[0] << std::endl << std::endl;
std::cout << "Using char that was static_cast from int: ";
std::cout << "isuit = " << isuit << std::endl << std::endl;
std::cout << "Using c-style cast to char: ";
std::cout << "(char)i[0] = " << (char)i[0] << std::endl << std::endl;
std::cout << "Using char variable assigned with static_cast from int: ";
std::cout << "jsuit = " << jsuit << std::endl << std::endl;
std::cout << "Using \"cout << 3\": " << 3 << std::endl << std::endl;
std::cout << "Using \"cout << static_cast<char>(3)\": " <<
static_cast<char>(3) << std::endl << std::endl;
std::cout << "Using char counter and static_cast to get int: " << std::endl;
for (char ci = 3; ci <= 6; ci++) {
std::cout << static_cast<int>(ci) << ": <" << ci << ">" << std::endl;
}
std::cout << std::endl << std::endl;
std::cout << "Using int counter and static_cast to get char: " << std::endl;
for (int ii = 3; ii <= 6; ii++) {
std::cout << ii << ": <" << static_cast<char>(ii) << ">" << std::endl;
}
return 0;
}
In this case static_cast does the same thing as the old-fashioned C-style cast.
By the way, in response to Zach L and Draco: for Windows machines, many of the non-printing ansii characters give interesting symbols that may (or may not) give something fun for you to work with. The above program prints symbols for Hearts, Diamonds, Spades, and Clubs on my Windows box (but not for my Linux box).
[edit]
When I said "print", I should have said "displays in a console window". Printers may or may not be able to display these characters.
[/edit]
Regards,
Dave