You have a structural problem. You're trying to create main(), followed by a function called is_valid_key), but you have some errors in how you did it.
The main() function (yes, it's technically a function, with a special name) should end with a closing curly brace, before the start of any other functions. This code has the closing curly brace at the very ...
Look at this line:
for (int i = 0; i < strlen(argv[i]); i++)
Here you're trying to iterate over all arguments in the command line when you should iterate only over the second argument. To fix this you can create a variable:
string x = argv;
for (int i = 0; i < strlen(x); i++)
or use the address:
for (int i = 0; i < strlen(&argv[i]); i++)...
I found out an approach to solve this-
int main(int argc, string argv)
for (int i=0; i<strlen(argv); i++ )
c[i] = argv[i];
if (argc ==2 && isdigit(c))
int k = c;
string ip = get_string("plaintext:");
This is a common newbie error. The problem lies here:
The isdigit() function and all of it's issomething() functions take a single char as input. But, argv is a string, not a single char. This code is taking a string and shoving it down isdigit's throat, so it chokes and coughs up a seg fault.
The code needs to check each char in argv...