This is a process of my code.

* get string by `scanf`
* store the string in an array `arr`
* repeat this work

Here's my code.

```c
#include <stdio.h>

int main(void)
{
    char str[10];
    char * arr[10];

    for(int i=0; i<3; i++) {
        scanf("%s", str);
        arr[i] = str;
        printf("%s %p\n", arr[i], str);
    }
    for(int i=0; i<3; i++)
        printf("%s\n", arr[i]);
    return 0;
}

```

Results:

```sh
aaa
aaa 0x7ffee773892e
bbb
bbb 0x7ffee773892e
ccc
ccc 0x7ffee773892e
ccc
ccc
ccc

```

Since `str` points same memory address, `arr` contains `ccc` only.
But that's not what I want, so I tried another one.

```c
#include <stdio.h>

int main(void)
{
    char * str;  /* This line is changed. */
    char * arr[10];

    for(int i=0; i<3; i++) {
        scanf("%s", str);
        arr[i] = str;
        printf("%s %p\n", arr[i], str);
    }
    for(int i=0; i<3; i++)
        printf("%s\n", arr[i]);
    return 0;
}

```

I changed `char str[10]` → `char * str` to avoid storing same strings. Obviously `str` points different address for each loop but it still doesn't work.

```c
#include <stdio.h>

int main(void)
{
    char * str;
    char * arr[10];

    for(int i=0; i<3; i++) {
        if (i == 0)
            str = "Hello";
        else if (i == 1)
            str = "World";
        arr[i] = str;
        printf("%s %p\n", arr[i], str);
    }
    for(int i=0; i<3; i++)
        printf("%s\n", arr[i]);
    return 0;
}

```

Results:

```
Hello 0x1074bbfa0
World 0x1074bbfa6
World 0x1074bbfa6
Hello
World
World

```

However, it works.

I don't know what's different between second and third.
Is there any way of getting strings independent to others?

+) fgets, gets were bad too.