C Reference String Operation: strcpy()

The function strcpy() copies the characters from one string to another string.

Note: the null termination is also copied.

Usage:

char * strcpy( char *target, const char *source);

The return value of the strcpy function is target.

strcpy() source code example:



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

	main()
	{
		char line[100];
		strcpy(line, "hello,world!");
		printf ("%s\n", line);
	}

Output of the example:



	hello,world!

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.