C Reference String Operation: strncat()

The strncat() function concatenates up to n characters of one string onto the end of another string.

Usage:

char *strncat(char *target, const char * source, size_t count);

Note: null character is added add the end. The target is returned by strncat() function.

strncat() source code example:


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

	main()
	{
		char line[100];
		strcpy(line, "hello");

		strncat(line, "world",2);
		printf ("%s\n",line);
	}

Output of the example:


	hellowo

This entry was posted in C Reference string.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.