My question is regarding the step of 'Validating the Key' in Caesar of Pset2 , while checking whether the key given by user consists of digits.
Here is my code :
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
int main (int argc, string argv[])
{
//Regarding command line argument
int x;
if ( argc==2)
{
for(int i =0 ,n=strlen(argv);i<n;i++)
{
if(isdigit(argv[1][i]))
{
}
//Convert the string to integer
x = atoi(argv[1]);
else
{
printf("Usage: %s key\n",argv[0]);
}
}
printf("Success\n");
//Print out key entered
printf("%i\n",x);
}
else
{
printf("Usage: %s key\n",argv[0]);
return 1;
}
}
I am getting the following errors :
caesar.c:14:32: error: incompatible pointer types passing 'string *' (aka 'char **') to parameter of type 'const char *'; dereference with * [-Werror,-Wincompatible-pointer-types]
for(int i =0 ,n=strlen(argv);i<n;i++)
^~~~
*
/usr/include/string.h:385:35: note: passing argument to parameter '__s' here
extern size_t strlen (const char *__s)
^
caesar.c:22:13: error: expected expression
else
^
2 errors generated.
make: *** [<builtin>: caesar] Error 1