Question: I'm looking for information about how to age data in a db, generally related to Oracle and Sql 
 Server, but any database would be good. Any examples or books containing examples of how the best 
 techniques would be cool.

Bob

Answer: 
In your source code, without much processing, probably the easiest way is with:

```
#define HI "hello world"
char str[] = HI " " HI " " HI;

```

This will declare a string of the requested value:

```
"hello world hello world hello world"

```

If you want *code* that will do it, you can use something like:

```
char *repeatStr (char *str, size_t count) {
    if (count == 0) return NULL;
    char *ret = malloc (strlen (str) * count + count);
    if (ret == NULL) return NULL;
    strcpy (ret, str);
    while (--count > 0) {
        strcat (ret, " ");
        strcat (ret, str);
    }
    return ret;
}

```

Now keep in mind this can be made more efficient - multiple `strcat` operations are ripe for optimisation to avoid processing the data over and over (a). But this should be a good enough start.

You're also responsible for freeing the memory returned by this function.

---

(a) Such as with:

```
// Like strcat but returns location of the null terminator
//   so that the next myStrCat is more efficient.

char *myStrCat (char *s, char *a) {
    while (*s != '\0') s++;
    while (*a != '\0') *s++ = *a++;
    *s = '\0';
    return s;
}

char *repeatStr (char *str, size_t count) {
    if (count == 0) return NULL;
    char *ret = malloc (strlen (str) * count + count);
    if (ret == NULL) return NULL;
    *ret = '\0';
    char *tmp = myStrCat (ret, str);
    while (--count > 0) {
        tmp = myStrCat (tmp, " ");
        tmp = myStrCat (tmp, str);
    }
    return ret;
}

```
You may try write own function. It will be work with single-length string also (i. e. duplication a single char). It use the function "strcat()" from the "string.h", so do not forget include this header.

```
char *
str_repeat(char str[], unsigned int times)
{
    if (times < 1)
        return NULL;

    char *result;
    size_t str_len = strlen(str);
    result = malloc(sizeof(char) * str_len + 1);

    while (times--) {
        strcat(result, str);
    }
    return result;
}

```

But, if you need only duplication of a string for print it, try macro

```
#define PRINT_STR_REPEAT(str, times) \
{ \
    for (int i = 0; i < times; ++i) \
        printf("%s", str); \
    puts(""); \
}

```

Results

```
PRINT_STR_REPEAT("-", 10); // ----------
puts(str_repeat("-", 10)); // ----------

PRINT_STR_REPEAT("$", 2); // $$
puts(str_repeat("$", 2)); // $$

PRINT_STR_REPEAT("*\t*", 10); // *   **  **  **  **  **  **  **  **  **  *
puts(str_repeat("*\t*", 10));  // *   **  **  **  **  **  **  **  **  **  *

PRINT_STR_REPEAT("*_*", 10); // *_**_**_**_**_**_**_**_**_**_*
puts(str_repeat("*_*", 10)); // *_**_**_**_**_**_**_**_**_**_*

```