summaryrefslogtreecommitdiff
path: root/reference/C/EXAMPLES/strcpy.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2008-01-27 11:37:44 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2008-01-27 11:37:44 +0100
commit7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch)
treeb1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/EXAMPLES/strcpy.c
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/EXAMPLES/strcpy.c')
-rw-r--r--reference/C/EXAMPLES/strcpy.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/reference/C/EXAMPLES/strcpy.c b/reference/C/EXAMPLES/strcpy.c
new file mode 100644
index 0000000..3580e9f
--- /dev/null
+++ b/reference/C/EXAMPLES/strcpy.c
@@ -0,0 +1,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);
+
+}