I'm trying to print the value of argv[1] to check if the program will run as expected. It compiles fine, but I keep getting 'segmentation fault' when the program runs.
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, string argv[])
{
//string text;
if (argc != 2)
{
printf("Usage: ./caesar key\n");
return 1;
}
else
{
if (isdigit(argv[1]))// this could be argv[argc - 1]
{
printf("%s\n", argv[1]);
return 0;
}
else
{
printf("Usage: ./caesar key\n");
return 1;
}
}
/*text = get_string("Plaintext: ")*/ //plaintext by user
}