I have
int i = 6;
and I want
char c = '6'
by conversion. Any simple way to suggest?
EDIT:
also i need to generate a random number, and convert to a char, then add a '.txt' and access it in an ifstream.
asciic
I have
int i = 6;
and I want
char c = '6'
by conversion. Any simple way to suggest?
EDIT:
also i need to generate a random number, and convert to a char, then add a '.txt' and access it in an ifstream.
Best Answer
Straightforward way:
Safer way:
Generic way:
Handy way:
C++ way: (taken from Dave18 answer)
Boss way:
Studboss way:
Joe's way:
Nasa's way:
Alien's way: '9'
God's way:
Peter Pan's way:
Santa Claus's way:
Gravity's way:
'6' (Jersey) Mikes'™ way:
SO way:
My way:
Comment: I've added Handy way and C++ way (to have a complete collection) and I'm saving this as a wiki.
Edit: satisfied?