so i am generating a random number and i want to store that random number as the character of itself... i don't know how to do this.
1 2 3
char t;
(unsigned (time(NULL)));
t = rand()%9;
i know this is wrong because the number between 1-9 is getting converted into the ascii character i just dont know how to prevent this? help.... sorry if this doesn't make any sense!!
Since the number is stored at the ascii value internally, you can simply "add" the value of '0'. Hence if you rand()%9 returns 0, you will get 0+'0', which would give you character '0'. The other numbers follow sequentially, so '0'+1 == '1', etc.