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++)...