Code:
#include<stdio.h>
void convert(char *str, int pn)
{
char ch;
char *words[] = {"ABC", "DEF", "GHI", "JKL", "MNO", "PRS", "TUV", "WXY"};
if (str[pn] == '\0')
{
printf("%s\n", str);
return;
}
ch = str[pn];
if (ch < '2')
convert(str, pn + 1);
else
{
str[pn] = words[ch - '2'][0];
convert(str, pn + 1);
str[pn] = words[ch - '2'][1];
convert(str, pn + 1);
str[pn] = words[ch - '2'][2];
convert(str, pn + 1);
if (ch == '7' || ch == '9')
{
str[pn] = words[ch - '2'][3];
convert(str, pn + 1);
}
str[pn] = ch;
}
}
int main(void)
{
convert("4663", 0);
return 0;
}
i was trying to get a program to run like wat handphone does... like a motorolla's i-Tap function where it will let the user to choose a variety of letters to form a meaningful word.
please help me to debug it