summaryrefslogtreecommitdiff
path: root/wk2/pset2
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-09 06:46:24 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-09 06:46:24 +0000
commit936ca14d805c0153f1e7daa7690b399e4d285d30 (patch)
tree1769a8f5fce5a12f40dca3e810d70fb73dc88495 /wk2/pset2
parente4a1fa2f3117c1871bb0296344937222f4d074a8 (diff)
Fri, Dec 8, 2023, 10:46 PM -08:00
Diffstat (limited to 'wk2/pset2')
-rw-r--r--wk2/pset2/caesar/caesar.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/wk2/pset2/caesar/caesar.c b/wk2/pset2/caesar/caesar.c
index ca787dc..75b52df 100644
--- a/wk2/pset2/caesar/caesar.c
+++ b/wk2/pset2/caesar/caesar.c
@@ -4,6 +4,19 @@
int main(int argc, string argv[])
{
int key = argv[1];
- //if (argc != 2 || (argv[1] % 1 != 0))
+ //if (argc != 2)
printf("%i\n", key);
}
+
+/*Implement your program in a file called caesar.c in a directory called caesar.
+Your program must accept a single command-line argument, a non-negative integer. Let’s call it
+for the sake of discussion.
+If your program is executed without any command-line arguments or with more than one command-line argument, your program should print an error message of your choice (with printf) and return from main a value of 1 (which tends to signify an error) immediately.
+If any of the characters of the command-line argument is not a decimal digit, your program should print the message Usage: ./caesar key and return from main a value of 1.
+Do not assume that
+will be less than or equal to 26. Your program should work for all non-negative integral values of less than . In other words, you don’t need to worry if your program eventually breaks if the user chooses a value for that’s too big or almost too big to fit in an int. (Recall that an int can overflow.) But, even if is greater than , alphabetical characters in your program’s input should remain alphabetical characters in your program’s output. For instance, if is , A should not become \ even though \ is positions away from A in ASCII, per asciitable.com; A should become B, since B is
+positions away from A, provided you wrap around from Z to A.
+Your program must output plaintext: (with two spaces but without a newline) and then prompt the user for a string of plaintext (using get_string).
+Your program must output ciphertext: (with one space but without a newline) followed by the plaintext’s corresponding ciphertext, with each alphabetical character in the plaintext “rotated” by k positions; non-alphabetical characters should be outputted unchanged.
+Your program must preserve case: capitalized letters, though rotated, must remain capitalized letters; lowercase letters, though rotated, must remain lowercase letters.
+After outputting ciphertext, you should print a newline. Your program should then exit by returning 0 from main.*/