summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/strcpy.c
blob: 3580e9f559930f05eafeb713d32b4bcd17103956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Purpose: Program to demonstrate the 'strcpy' function.
 * Author:  M J Leslie
 * Date:    12-Mar-94
*/

#include <string.h>	/* strcpy */

main()
{
  char text1[20]="martin";		/* string buffer	*/
  char text2[20]="leslie";		/* string buffer	*/

  printf (" original string contents are: %s\n", text1);
					/* Copy text2 into text1. 
					   If text1 is smaller that text2
					   it will probably overwrite
					   something!		*/
  strcpy(text1, text2);
  printf (" new string contents are: %s\n", text1);

  strcpy(text1, "linux");
  printf (" final string contents are: %s\n", text1);

}