int main(int argc, string argv[])
string enteredtext = get_string("plain text:");
printf("Entered text by user: %s\n", enteredtext);
int n = strlen(enteredtext);
printf("length of entered text: %i\n", n);
string key = argv[1];
int counter = int argv[0];
while (counter != '\0'; counter = counter + 1)

The last two lines of the above code can be ignored as I kept to just give an idea of what I intend to do later.

With argv[1], an array is formed. Now argv[1] is apparently a location with a space. This location space will contain whatever key entered by the user. We need not worry about the length of the array of argv[1] as first the user will enter the key, and based on the key, the length of the array argv[1] is determined?

I am not sure how to denote individual elements of the array argv[1]. Suppose the user enters as key 450R.

argv[0] = 4

argv[1] = 5

argv[2] = 0

argv[R] = R

There is an overlap as argv[1] is supposed to be

string key = argv[1]

1 Answer 1


argv[1] is a string and each char in the string is index 0, 1, 2....etc. The correct notation is argv[1][0], argv[1][1], argv[1][2]..... etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .