I'm having a problem with argv[]: the code doesn't seem to 'see' it!! With a key that's either too long or too short, the program behaves as expected (prints out error message, exits).
But if I input a key that's one string long, nothing happens. I exit the program, and that's all.
To see what's wrong I'm trying to have the program print the key: nothing happens.
I have no idea why, at this point.
Help would be much appreciated!
(I'm just copying and pasting the first part of the code)
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, string argv[])
{
//first I check whether the user has inputed a key made of more than one element
if (argc != 2)
{
printf("Usage: ./caesar key, key should be a positive integer");
}
return 1;
printf("%s\n",argv[1]);
//Now I'm excluding non-numeric keys. I check every char of argv [1] with isdigit. I do it by implementing a loop:
for (int i = 0; i < strlen(argv[1]); i++)
{
if (isdigit(argv[1][i]) == 0)
{
return 1;
}
}
}