I posted earlier about a code I created that converts Alpha Phone numbers into numeric ones. It turns out that doesn’t work very well. It messes up at 789.
Here is the updated version
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(void)
{
char ch;
int storing;
printf(“Enter phone number: “);
while ((ch = getchar()) != ‘\n’)
{
if (ch >= ‘A’ && ch <= ‘R’)
{
storing = ((ch – ‘A’) / 3)+2;
printf(“%d”, storing);
}
else if (ch >= ‘S’ && ch <= ‘Y’)
{
storing = ((ch – ‘A’)-1) / 3 + 2;
printf(“%d”, storing);
}
else if (ch == ‘-‘)
{
printf(“%c”, ch);
}
else if((ch>=’0′ && ch<=’9’))
{
storing= ch – ‘0’;
printf(“%d”, storing);
}
// putchar(ch);
}
system(“pause”);
return 0;
}