So I'm a total noob to C programming and I've got no idea how to make this program. I've started on it, but I'm still completely lost. It's an entry level C programming class that I'm in so it must not be too complicated, but I'm coming up blank.
Basically, I need to make a substitution cipher that allows me to input an encryption key and then have that encryption key encrypt a seven letter word, but only after I've made sure that the word is within the ABRACADABRA alphabet.
The assignment is problem 3, found at http://ece15.ucsd.edu/Labs/lab2.pdf .
Here's what I've written so far. All I'm trying to do is compare one array to another array to make sure that every letter in my "word" array matches one of the letters in my "natural" array (that has the ABRACADABRA alphabet in it). I haven't even started on the encryption part yet, but I think I have the algorithm worked out for that.
Code:
int main()
{
int i=0,w=0,j=0;
char nat[5]= {'a','b','c','d','r'};
char in[5], inw[7];
printf("Enter key: ");
for(i=0;i<5;i++)
{
in[i] = getchar();
}
printf("Enter word: ");
for(w=0;w<7;w++)
{
inw[w] = getchar();
}
while(j<5)
{
while(inw[w] != nat[j])
{
j++;
}
if(inw[w] == nat[j])
{
w++;
j=0;
}
}
if(j == 5)
{
printf("You did not speak ABRACADABRA to me!\n");
}
return 0;
}
//else if(w ==7)
You can see I barely started to work on the next part of the problem, but I need to figure out how to do this check first...
Agh! So frustrating! I don't expect anyone to do my homework for me, just some hints or some pointers would help me a LOT.