# Keystrokes that equal tens digit

How would I use the keystroke of a letter represent a colunm of say ones,tens or hundreds.
In other words if I use' a' to represent the hundreds spot 's' to represent the tens spot and 'f' to represent the one
and if I typed in a 1 s 2 and f 9 this would appear on the screen as 129. And if I then type 'a 1', 's 1 and 'f' 0
the sum of the two would come out correctly.

• : How would I use the keystroke of a letter represent a colunm of say ones,tens or hundreds.
: In other words if I use' a' to represent the hundreds spot 's' to represent the tens spot and 'f' to represent the one
: and if I typed in a 1 s 2 and f 9 this would appear on the screen as 129. And if I then type 'a 1', 's 1 and 'f' 0
: the sum of the two would come out correctly.
:
[blue]multiply the value of the digit by either 1, 10, or 100 then add that to the current value of the accumulator integer.
[code]
std::string str;
int total = 0;
for(;;)
{
cout << "enter a litter followed by a digit ...";
cin >> str;
int digit = atoi(&str.c_str()[1]);
switch(str[0])
{
case 'f':
// 1s place, so do nothing
break;
case 's':
digit *= 10; // 10's place
break;
case 'f':
digit *= 100; // 100's place
break;
}
total += digit;
}
[/code]