I am trying to create an application that can replace a character to a number. Let say A = 2 and F=3 if I write AFAF = 2323 should be the result, Please help.
#include <stdio.h>
#include <string.h>
int main(){
char *test;
char *result;
int i,e = 0;
int ch;
while((ch = getchar()) != '\n'){
if(e < 5){
*test++=ch;
e++;
}
}
*test = '\0';
for(i =0; i < 5; i++){
if(strcmp(test++,"A") == 0 || strcmp(test++,"B")==0 || strcmp(test++,"C")==0){
result[i] = "2";
}else if (strcmp(test++,"D") == 0 || strcmp(test++,"E")== 0 || strcmp(test++,"F")== 0){
result[i] = "3";
}
}
for(i = 0; i<5;i++){
printf("%s", result[i]);
}
return 0;
}