#include <stdio.h>
#include <string.h>
int main()
{
char cipher[5][5] = {
{'a', 'b', 'c', 'd', 'e'},
{'f', 'g', 'h', 'i', 'k'},
{'l', 'm', 'n', 'o', 'p'},
{'q', 'r', 's', 't', 'u'},
{'v', 'w', 'x', 'y', 'z'}
};
char cm;
char *original;
char *portion;
printf("Enter ciphered message: ");
scanf("%s", &cm);
original = strdup(&cm);
portion = strtok(original, "-");
while (portion != NULL){
int i = portion[0]-'0';
int j = portion[1]-'0';
printf("%c", cipher[i][j]);
portion = strtok(NULL, "-");
}
return 0;
}
Hello, I'm a new computer science student and I'm already having a problem. I'm writing a polybius cypher and I can't seem to get the user input saved correctly to use at strdup
With input i.e.: 00-11-22-33-44 I should receive "agntz" but I can't get it to print. I'm new here so I apologize if I haven't formatted my question correctly.