Skip to content

Instantly share code, notes, and snippets.

@vinay13
Created August 25, 2014 18:53
Show Gist options
  • Save vinay13/b7d422de3cbc9db16ecf to your computer and use it in GitHub Desktop.
Save vinay13/b7d422de3cbc9db16ecf to your computer and use it in GitHub Desktop.
keypadChar to no
//hashmap phone keypad
#include <stdio.h>
#include <string.h>
int main()
{
char str[]="facebook";
const char hash[10][4]={"","","abc","def","ghi","jkl","mno","pqr","stu","vxz"};
int i;
for(i=0;i<strlen(str);i++)
{
int k=0;
int j=0;
if(str[i]==hash[j][k])
{
printf("%d",j);
j=0;
continue;
}
else
{
while(str[i]!=hash[j][k])
{
k++;
if(k==4 || str[i]=='\0' )
{
j++;
k=0;
//break;
}
else
continue;
}
printf("%d",j);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment