Question: I want to write a program where it duplicates every letter in a given string.

For example, if the input is `abc` then the output would be `aabbcc`.

How can I do this?

Here is my code so far. It only copies the string:

```
#include <stdio.h>

int main () {
    char str_in[100];
    char str_out[200] = "";
    int i;

    printf("Enter a word: ");
    scanf("%s", str_in);

    for (i = 0; i < sizeof(str_in); i++) {
        str_out[i] += str_in[i];
    }

    printf("Duplicated word: %s", str_out);

    return 0;
}

```

Answer: 
For starters the destination character array should be at least two times larger than the source array.

The loop that performs the copying can look the following way

```
size_t j = 0;
for ( size_t i = 0; str_in[i] != '\0'; i++ ) 
{
    str_out[j++] = str_in[i];
    str_out[j++] = str_in[i];
}

str_out[j] = '\0';

```
```
#include <stdio.h>

int main () {
    char str_in[100];
    char str_out[200] = "";
    int i, j;

    printf("Enter a word: ");
    scanf("%s", str_in);

   j=0;
   for (i = 0; i < sizeof(str_in); i++) {
       str_out[i] = str_in[j];
       str_out[i+1] = str_in[j];
       i++;
       j++;
   }

   printf("Duplicated word: %s", str_out);

   return 0;
}

```