I'm very new to all this and so am struggling a bit with the for loop. Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
// Promts user if inputs more than one command-line argument
if (argc != 2)
{
printf("Usage: ./caesar key\n");
return 1;
}
// Prompts user if key is composed of characters other than digits
for (int i = 0, n = strlen(argv[1]); i < n; i++)
{
if (!isdigit(argv[1][i]))
{
printf("Usage: ./caesar key\n");
return 1;
}
else
{
printf("Success!\n");
return 0;
}
}
}
I'm not sure I understand how I can make my loop work for "./caesar 20x", so that it prompts the user for another key. I've been trying to get my head around it and can't figure itout, would appreciate any leads.