Code:
//included libraries
#include <stdio.h>
#include <math.h> //is this needed?
//Main Function
int main() {
//Most of your program should go here.
//Declare strings and arrays
int i,j;
char name[18];
char cipher[25];
char alphabet[25] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
/*
Note that the alphabet has 26 letters, not 25. A simpler way:
char alphabet[]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
Now alphabet[] will have 27 spaces. 26 for the letters, and one
more for the end of string char: '\0', which you can't see here, but
is required for string functions, in C.
*/
//Ask for the cipher
printf("What is your substitution cipher?\n");
//Scan for the cipher
for(i=0; i<26; i++){
scanf("%c", &cipher[i]);
}
/* why not the simpler
scanf("%s", cipher); ?
*/
//Ask for the users name
printf("What is your name?\n");
scanf("%s", &name);
/* correct is:
scanf("%s", name);
the name of the array, IS the address to the array's first element
*/
return 0;
}