Question: Say that I have this part of code. If user does not enter the file names as command line arguments I want to ask him again so as to enter them now but as it seems I cannot have access in argv[1] and argv[2]. For example when the first scanf is executed segmentation fault occurs. But in this case how can I read the arguments and place them into argv[1] and argv[2]?
Thanks in advance for your help!

```
int main (int argc, char **argv)
{
    if (argc != 3)
    {
        printf("You did not enter two files.\n");
        printf("You can now enter those two files.\n");
        printf("file 1: ");
        scanf("%s", argv[1]);
        printf("file 2: ");
        scanf("%s ", argv[2]);
    }

    printf("%s\n", argv[1]);
    printf("%s\n", argv[2]);

    FILE *file1 = fopen(argv[1], "r");
    FILE *file2 = fopen(argv[2], "r");
}

```

Answer: 
A segmentation fault occurs because length of the argv array is determined when the user runs the program. If you run a program like this:

```
./programName

```

argv is only 1 element long. It's impossible to access argv[1] or argv[2] after that. Still, You can get the necessary data and save them in regular variables.
Placing them in `argv` is the wrong approach. Much better to do something like this:

```
int main (int argc, char **argv)
{
    char f1[255];
    char f2[255];
    if (argc != 3)
    {
        printf("You did not enter two files.\n");
        printf("You can now enter those two files.\n");
        printf("file 1: ");
        scanf("%s", f1);
        printf("file 2: ");
        scanf("%s ", f2);
    } else {
        strcpy(f1, argv[1]);
        strcpy(f2, argv[2]);
    }
    FILE *file1 = fopen(f1, "r");
    FILE *file2 = fopen(f2, "r");
}

```

You should avoid writing to `argv`. That's in general a bad idea.