Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- int main(int argc, string argv[])
- {
- //Check the command line for 2 line arguments
- if (argc != 2)
- {
- printf("ERROR: Enter one key on command-line\n");
- return 1;
- }
- // Put argv into an integer (k).
- int k = atoi(argv[1]);
- if (k < 0)
- {
- printf("Enter a positive value\n");
- return 1;
- }
- // Check if (k) is only digits.
- for(int i = 0; i < strlen(argv[1]); i++)
- if(isalpha(argv[1][i]))
- {
- printf("Usage: ./caesar key\n");
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment