I am stuck with Caesar, validating the key. Before i use the atoi function, I want to check if argv consists of digits. I watched the linear search movie but is is to cryptic for me.
I have to itterate through the array en and check if every character is a digit or not. Unfortunately, I don't get the code right. Can you give me some advice?
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
//variables
int i;
int main(int argc, string argv[])
{
if (argc == 2)
{
printf("Success\n");
for (i = 1; argv[i] != '\0'; i++)
{
printf("%s\n", argv[i]);
}
// check te make sure that each argument is a digit
if (isdigit(argv[i]) == 0)
{
printf("check\n");
}
}
else
{
printf("./caesar key\n");
}
return 1;
}