Question: So, I'm trying to code a strcat function using pointers, just for studying purposes.

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

char *strcpyy(char *dest, char *orig){
    char *tmp = dest;
    while (*dest++ = *orig++);
    return tmp;
}

char *strcatt(char *dest, char *orig){
    strcpyy(dest + strlen(dest), orig);
    return dest;
}

int main(){
    char *a = "one";
    char *b = "two";
    printf("%s", strcatt(a,b));
}

```

When I run this code, the output is empty. Can anyone point out the problem?

Answer: 
You declared two pointers to string literals

```
char *a = "one";
char *b = "two";

```

You may not append one string literal to another.

Instead you need to define the variable `a` as a character array large enough to contain the appended string literal pointed to by the pointer `b`.

And the both functions should be declared like

```
char *strcpyy(char *dest, const char *orig);

char *strcatt(char *dest, const char *orig);

```

Also as you are using standard C string functions like `strlen`

```
strcpyy(dest + strlen(dest), orig);

```

then it will be logically consistent to use standard C function `strcpy` instead of your own function `strcpyy`.

Otherwise without using standard string functions your function `strcatt` can look the following way

```
char * strcatt( char *s1, const char *s2 )
{
    char *p = s1;

    while ( *p ) ++p;
    while ( ( *p++ = *s2++ ) != '\0' );

    return s1;
}

```

Here is a demonstration program.

```
#include <stdio.h>

char * strcatt( char *s1, const char *s2 )
{
    char *p = s1;

    while ( *p ) ++p;
    while ( ( *p++ = *s2++ ) != '\0' );

    return s1;
}

int main( void ) 
{
    char a[7] = "one";
    const char *b = "two";

    puts( strcatt( a, b ) );
}

```

The program output is

```
onetwo

```
You cannot modify "string literals". Those are not *mutable*.

The usual *idiom* for this sort of operation is to build up a string in a temporary *working buffer* that *should be* pre-dimensioned large enough to hold all that is required.

The following also shows more obvious code in both your functions.

```
#include <stdio.h>

char *strcpyy( char *dst, const char *org ) {
    for( char *p = dst; (*p++ = *org++) != '\0'; /**/ )
        ; // loop
    return dst;
}

char *strcatt( char *dst, const char *org ) {
    char *p = dst;
    while( *p != '\0' )
        p++; //loop
    while( (*p = *org++) != '\0' )
        p++; // loop
    return dst;
}

int main(){
    const char *a = "one ";
    const char *b = "two ";
    const char *c = "three";

    char wrk[ 64 ]; // sufficient mutable space defined

    printf( "%s\n", strcatt( strcatt( strcpyy( wrk, a ), b ), c ) );

    return 0;
}

```

```
one two three

```