Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, string argv[])
- {
- if (argc == 2 )
- {
- int l = strlen(argv[1]);
- for (int i = 0; i < l; i++)
- {
- isdigit(argv[1][i]);
- }
- }
- else
- {
- printf("Usage: ./caesar key\n");
- return 1;
- }
- //printf("Success\n");
- int a = atoi (argv[1]);
- //printf("%i\n", a);
- string s = get_string("plaintext: ");
- printf("ciphertext: ");
- int m = strlen(s);
- for (int i = 0; i < m; i++)
- {
- if (s[i] == 90 || s[i] == 122)
- {
- s[i] = s[i] - 26;
- }
- if (isalpha(s[i]))
- {
- int p = s[i] + a;
- char c = p;
- printf("%c", c);
- }
- else
- {
- printf("%c", s[i]);
- }
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement