Use strncat() function to append two string together - C String

C examples for String:String Function

Description

Use strncat() function to append two string together

Demo Code

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

char str2[] = "abcdefghijklmnopqrstuvwxyz";

int main( void )
{
    char str1[27];
    int n;//from   w  ww. ja  v  a  2 s.c  om

    for (n=1; n< 27; n++)
    {
        strcpy(str1, "");
        strncat(str1, str2, n);
        puts(str1);
    }
    return 0;
}

Result


Related Tutorials