Append two string together - C String

C examples for String:String Function

Description

Append two string together

Demo Code

#include <stdio.h>

#define MAXLINE 1000//from  ww w  .  ja v  a  2s .c  o  m

void str_cat(char *s, char *t);
int getchars(char *s, int max);

int main(void)
{
    char *s="this is a test", *t="this is another test";

    str_cat(s, t);
    printf("cat: %s\n", s);

    return 0;
}

void str_cat(char *s, char *t){
    while (*s)
        ++s;
    while (*s++ = *t++)
        ;
}

Related Tutorials