Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- bool only_digits(string s);
- int main(int argc, string argv[])
- {
- if (argc != 2)
- {
- printf("Usage: argc != 2\n");
- return 1;
- }
- bool check_key = only_digits(argv[1]);
- if (check_key != true)
- {
- printf("Invalid key\n");
- return 1;
- }
- return 0;
- }
- bool only_digits(string s)
- {
- for (int i = 0; i < strlen(s); i++)
- {
- if (isdigit(s[i]))
- {
- return s;
- }
- else if (isdigit(s[i]) == 0)
- {
- return false;
- }
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement