I want to use a given string (given as console app argument) within the main-method and don't know how to assign the console app argument to a string variable which is declared and used in the main method:
console:
~/substitution/ $ ./test FOEFJEOWJFWEFOJ (<- wanted argument)
code:
int main (int argc, char* argv[])
{
string argumentString;
In other words: How do I create a string argumentString with the content of the main-method argument argv[]?
Until now the following is my closest approach.. but with that code I get an "expected expression" with a pointer to key = argv[]
int main(int argc, char *argv[])
{
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string plain;
string key;
string cipher;
int i;
int j;
int n;
int o;
if (argc > 2)
{
printf("Only 1 Argument allowed");
return 1;
}
if (argc < 2)
{
printf("./substitution KEY\n");
return 1;
}
key = argv[];
if (strlen(key) == 26)
{