I have a program (encrypt.exe) that waits for user input using cin.getline()
to my understanding, cin.getline will take the input and parse it out over an array.
so for example lets say i run the program and it asks for text...
it type in "test"
my progarm will basically do this:
scratch[0] = 't';
scratch[1] = 'e';
scratch[2] = 's';
scratch[3] = 't';
scratch[4] = '\0';
Now what i want to do is avoid having the user input text by passing the text through the command line.
I am using main(int argc, char **argv) to do this.
so if i run the program like this... encrypt.exe test
i want it to do the same as above.
but the problem is "test" is entered in as one long char into argv[1].
how can i parse argv[1] to scratch[] so i get the same result as above... i.e.
scratch[0] = 't';
scratch[1] = 'e';
scratch[2] = 's';
scratch[3] = 't';
scratch[4] = '\0';
i know i can probably write some simple loop...but what fucition do i use to parse argv[1]?
i hope i made my probelm clear.
Thaks guys
to my understanding, cin.getline will take the input and parse it out over an array.
so for example lets say i run the program and it asks for text...
it type in "test"
my progarm will basically do this:
scratch[0] = 't';
scratch[1] = 'e';
scratch[2] = 's';
scratch[3] = 't';
scratch[4] = '\0';
Now what i want to do is avoid having the user input text by passing the text through the command line.
I am using main(int argc, char **argv) to do this.
so if i run the program like this... encrypt.exe test
i want it to do the same as above.
but the problem is "test" is entered in as one long char into argv[1].
how can i parse argv[1] to scratch[] so i get the same result as above... i.e.
scratch[0] = 't';
scratch[1] = 'e';
scratch[2] = 's';
scratch[3] = 't';
scratch[4] = '\0';
i know i can probably write some simple loop...but what fucition do i use to parse argv[1]?
i hope i made my probelm clear.
Thaks guys
