I need to "decode" a string into numbers. it should convert
1=ij 2=abc 3=def
4=gh 5=kl 6=mn
7=prs 8=tuv 9=wxy
0=oqz
so i made a code where i use a dynamic string array which should get filled up according to the above table, but when i try to print the output string i don't get nothing. What's wrong? Any help appreciated. Here's the code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
int b;
while(1)
{
cin>>a;
if(a!="-1")
{
cin>>b;
string input;
string* arrconv = new string[30];
for(int i=0; i<b; i++)
{
cin>>input;
for(int j=0; j<input.length(); j++)
{
if((input[j]=='i')||(input[j]=='j'))
arrconv[i][j]='1';
else if((input[j]=='a')||(input[j]=='b')||(input[j]=='c'))
arrconv[i][j]='2';
else if((input[j]=='d')||(input[j]=='e')||(input[j]=='f'))
arrconv[i][j]='3';
else if((input[j]=='g')||(input[j]=='h'))
arrconv[i][j]='4';
else if((input[j]=='g')||(input[j]=='h'))
arrconv[i][j]='5';
else if((input[j]=='m')||(input[j]=='n'))
arrconv[i][j]='6';
else if((input[j]=='p')||(input[j]=='r')||(input[j]=='s'))
arrconv[i][j]='7';
else if((input[j]=='t')||(input[j]=='u')||(input[j]=='v'))
arrconv[i][j]='8';
else if((input[j]=='w')||(input[j]=='x')||(input[j]=='y'))
arrconv[i][j]='9';
else if((input[j]=='o')||(input[j]=='q')||(input[j]=='z'))
arrconv[i][j]='0';
}
string wtf=arrconv[i];
cout<<arrconv[i].length()<<endl<<wtf;
}
}
system("pause");
}
return 0;
}