/* Program rot_string performs a Caeser Cipher on text read from standard input, and writes the ciphertext to standard output. */ #include #include int main() { int character, rotation, length, i, j; char str[256], cipher[256]; printf("Input a string to rotate.\n"); fgets(str, sizeof(str), stdin); /* get length of string */ length = strlen(str); printf("Input string: %s\n", str); printf("Length of string: %d\n", length); /* loop through all possible combinations */ for (i=1; i<=26; i++) { /* loop through the string */ for (j=0; j 64)) { character = character + rotation; if (character > 90) { character = character - 26; } } else { /* if character in a - z, rotate it */ if ((character < 123) && (character > 96)) { character = character + rotation; if (character > 122) { character = character - 26; } } } /* send possibly modified character to output */ cipher[j] = character; } /* print out the output string */ printf("For offset %2d, cyphertext is %s", i, cipher); } } /* end main */