Question: I'm trying to write a response into a variable, and I can't figure out how to do it.

This doesn't work - screws up memory, but no protection errors:

```
for (int i = 0; i < 20; i++) {
    list[i] = 'a';
}

```

Same with this - memory screwed up:

```
for (int i = 0; i < 20; i++) {
    *(((int*)(list))+i) = 'a';
}
//I don't think this is a string issues as this doesn't help:
//*(((int*)(list))+20) = '\0';

```

This causes a bus error:

```
for (int i = 0; i < 20; i++) {
    *list[i] = 'a';
}

```

*This works as desired:*

```
*list = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

```

**What am I doing wrong?**

**P.S.** `list` is `char**`.

Answer: 
Since you want an array of bytes then `char**` is wrong – that's a pointer to a pointer to `char`. You want `char*` for an array, but if it's fixed length I'd declare it as `char list[20]`.

It seems like you want to write something like this:

```
char list[20];
for (int i = 0; i < 20; i++) {
    list[i] = 'a';
}

```

Or if you want heap allocation use

```
char *list = malloc(20);

```

---

Since we are reduced to guessing, I think that you meant to say that `*list` is an array of bytes. In which case the code would be like so:

```
char **list = get_list_from_somewhere();
*list = malloc(20);
for (int i = 0; i < 20; i++) {
    *list[i] = 'a';
}

```
How did you initialize your `list`? 

```
char** list;

```

doesn't work in this case you'll have to have something like

```
char* list[20];

```

or dynamically allocated.