I want users to enter 2 digits using c=ReceiveByte() command. For example, I want the user to do the following :
Enter 5
Enter 3
Output number 53 in ascii value on screen ( using hyperterminal )
Store number in a single array
Use that number for other loops etc.
My draft code is :
.
.
int c1[3];
c1[0]=ReceiveByte();
c1[1]=ReceiveByte();
.
.
for(i=0;i<3;i++)
TransmitByte(c1[i]);
.
.
Is this right ? or am I storing the 2 digits incorrectly ?
Thanks alot for your help !
For output, you don't need to modify c1[0] and c1[1] since these already contain the characters as entered. As your code stands you just need to make sure that c1[2] contains a valid character, e.g.
c1[2] = '\n';
BTW, if you need to get the entered number as an int:
int num = (c1[0] - '0') * 10 + (c1[1] - '0');