r/C_Homework • u/danieleldr3d • Feb 24 '17
Caeser Cipher Help!
I'm tasked with creating a cipher using one function. It must read in a string of no more than 80 characters and a number. The cipher must be applied to every lower case character in the string.
Here's what I've got so far:
include <stdio.h>
int main() { char str1[80]; int cipher; int i; char c;
printf("Enter any message of no more than 80 characters: \n");
fgets(str1, 80, stdin);
printf("How many shifts of the alphabet would you like to take place?\n"); scanf("%i", &cipher);
for(i=0; str1[i]!='\0'; i++) { if((str1[i] > 96) && (str1[i] < 123)) (str1[i] + cipher); }
c=((str1[i]-97+cipher)%26)+97;
printf("%s\n", c);
return 0; }
View all comments
Show parent comment
1
u/dmc_2930 Feb 28 '17
I can't tell exactly how your code is structured. Try doing the four spaces thing on each line.
Also, describe what you think it's doing versus what it's actually doing. Show me the good and bad input and output.
Debugging is a skill......