#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <cs50.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if ((int)argv[1] > 2147483580)
{
printf("Usage: ./caesar key");
}
else
{
printf("Usage: ./caesar key");
}
if (argc ==2 && isdigit(argv[1]))
{
int k = atoi(argv[1]);
string ip = get_string("plaintext:");
}
}
//char sum
This is the partial code which only takes input . If you run using ./ceaser
it outputs correctly but upon entering acceptable value like ./ceaser 4
it outputs
~/Caesar/ $ ./ceaser 4
Segmentation fault
I tried with another approach but got the same error
long a = 2147483580;
if ((int)argv[1] > a)
{
printf("Usage: ./caesar key");
}
else
{
if (argc ==2 && isdigit(argv[1]))
{
int k = atoi(argv[1]);
string ip = get_string("plaintext:");
}
else
{
printf("Usage: ./caesar key");
}
}
Help me out with this!!