I have project in my class where I have to print a "coded message". The user is to input numbers that represent an alphabet array, then I need to convert those numbers into the letters of the array. Any help would be greatful as I have been beating my head on my keyboard for a couple of days now. Here is my code:
Code:
#include <stdio.h>
int main(void){
char alphabet[] = "0ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char entry[15];
size_t i, j;
printf("%s%25s\n", "Alpha Number", "Alpha Letter\n");
for(i = 1; i < 53; ++i){
printf("%12u%22c\n", i, alphabet[i]);
}
printf("Type a coded message. Separate whole numbers with a comma:\n");
scanf("%14s", entry);
printf("%s%25s\n", "Alpha Number", "Alpha Letter\n");
for(j = 0; j < 15; ++j){
for(i = 1; i < 53; ++i){
if(entry[j] == ','){
++entry[j];
}
if(alphabet[j] == entry[i]){
printf("%12c%22u\n", entry[j], alphabet[entry[j]]);
}//End IF
}//End inner loop
if(entry[j] == '\0'){
j = 999;
}//End if
}//End outer loop
printf("Your coded message is:\n%c", alphabet[entry[i]]);
}//End program