logicallayer
asked on
convert int to char (ex int 59 to ch1 ='5' , ch2='9'?
I was wondering if I can do it to convert a two digit int to a char for each digit
for example I have a clock that can go up to 59, I want assign the 5 to ch1 and the 9 to ch2
I was thinking to use bits but considering we are talking about awhole 16bits which int has, it would be hard to get the actual number....
there must be a way in which I treat an int as if it's an array of chars or something...
for example I have a clock that can go up to 59, I want assign the 5 to ch1 and the 9 to ch2
I was thinking to use bits but considering we are talking about awhole 16bits which int has, it would be hard to get the actual number....
there must be a way in which I treat an int as if it's an array of chars or something...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi LL,
Depending on how finely we slice we slice the subtleties, there are probably a dozen ways to do this in C.
Kent
Depending on how finely we slice we slice the subtleties, there are probably a dozen ways to do this in C.
Kent
ASKER
although I just found
itoa(int,string,base) will do the job for me
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/
but I was actually trying to figure out some way similar to yours,
/clap
impressed it's nice.