Hello I made a little Al Bhed translator, a language in Final Fantasy X. It works fine for only doing one word, I would like it to do phrases too. I can input the phrase fine but it only will translate the first word, it stops at the first whitespace it finds. What can I do to have it do the whole string?
here is the code I am using:
Thanks in advance for the help.Code:#include <iostream.h> #include <string.h> void main() { char ag='y'; while(ag=='y'||ag=='Y') { int size; int i; char *albhed=new char [256]; char *eng=new char [256]; char *trans=new char [256]; char *buf=new char [1]; char *enoab=new char[1]; cout<<"This is a bilingual translator.\nIt will translate to and from Al Bhed and English."<<endl; cout<<"What language would you be translating from?\n\nE=English\tA=Al Bhed"<<endl; cin>>enoab; strlwr(enoab); if(enoab[0]=='e') { cout<<"This will translate the English language into the Al Bhed language."<<endl; cout<<endl<<"Enter the English word or phrase to tanslate: "<<flush; cin.ignore(); cin.getline(eng,256,'\n'); strlwr(eng); size=strlen(eng); for(i=0;i<=size;i++) { buf[0]=eng[i]; if(buf[0]=='a'){trans[i]='y';}if(buf[0]=='b'){trans[i]='p';} if(buf[0]=='c'){trans[i]='l';}if(buf[0]=='d'){trans[i]='t';} if(buf[0]=='e'){trans[i]='a';}if(buf[0]=='f'){trans[i]='v';} if(buf[0]=='g'){trans[i]='k';}if(buf[0]=='h'){trans[i]='r';} if(buf[0]=='i'){trans[i]='e';}if(buf[0]=='j'){trans[i]='z';} if(buf[0]=='k'){trans[i]='g';}if(buf[0]=='l'){trans[i]='m';} if(buf[0]=='m'){trans[i]='s';}if(buf[0]=='n'){trans[i]='h';} if(buf[0]=='o'){trans[i]='u';}if(buf[0]=='p'){trans[i]='b';} if(buf[0]=='q'){trans[i]='x';}if(buf[0]=='r'){trans[i]='n';} if(buf[0]=='s'){trans[i]='c';}if(buf[0]=='t'){trans[i]='d';} if(buf[0]=='u'){trans[i]='i';}if(buf[0]=='v'){trans[i]='j';} if(buf[0]=='w'){trans[i]='f';}if(buf[0]=='x'){trans[i]='q';} if(buf[0]=='y'){trans[i]='o';}if(buf[0]=='z'){trans[i]='w';} } } if(enoab[0]=='a') { cout<<"This will translate the Al Bhed language into the English language."<<endl; cout<<endl<<"Enter the Al Bhed word or phrase to tanslate: "<<flush; cin.ignore(); cin.getline(albhed,256,'\n'); strlwr(albhed); size=strlen(albhed); for(i=0;i<=size;i++) { buf[0]=albhed[i]; if(buf[0]=='a'){trans[i]='e';}if(buf[0]=='b'){trans[i]='p';} if(buf[0]=='c'){trans[i]='s';}if(buf[0]=='d'){trans[i]='t';} if(buf[0]=='e'){trans[i]='i';}if(buf[0]=='f'){trans[i]='w';} if(buf[0]=='g'){trans[i]='k';}if(buf[0]=='h'){trans[i]='n';} if(buf[0]=='i'){trans[i]='u';}if(buf[0]=='j'){trans[i]='v';} if(buf[0]=='k'){trans[i]='g';}if(buf[0]=='l'){trans[i]='c';} if(buf[0]=='m'){trans[i]='l';}if(buf[0]=='n'){trans[i]='r';} if(buf[0]=='o'){trans[i]='y';}if(buf[0]=='p'){trans[i]='b';} if(buf[0]=='q'){trans[i]='x';}if(buf[0]=='r'){trans[i]='h';} if(buf[0]=='s'){trans[i]='m';}if(buf[0]=='t'){trans[i]='d';} if(buf[0]=='u'){trans[i]='o';}if(buf[0]=='v'){trans[i]='f';} if(buf[0]=='w'){trans[i]='z';}if(buf[0]=='x'){trans[i]='q';} if(buf[0]=='y'){trans[i]='a';}if(buf[0]=='z'){trans[i]='j';} } } cout<<endl<<"The translation is:"<<trans<<endl; cout<<endl<<"Do it again? y/n"<<endl; cin>>ag; } }
Penpen420



LinkBack URL
About LinkBacks


