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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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?