Details about my goal
In C, my program is supposed to take an input from command line, read it, make sure that it is a digit and then print out "Success" if true, "Usage: ./caesar key" if false.
Expected results
./caesar 33
Success
or
./caesar zzz
Usage: ./caesar key
Actual results
./caesar 33
Segmentation error
What I've tried
int main (int argc, string argv[])
{
if (argc == 2)
{
if (isdigit(argv[1]))
{
printf("Success\n");
return 0;
}
or
if (argc == 2)
{
if (isdigit(argv[0][1]))
{
printf("Success\n");
return 0;
}
or
int main (int argc, string argv[])
{
if (argc == 2 && isdigit(argv[1]))
{
printf("Success\n");
return 0;
}