We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd6efe6 commit 9712df4Copy full SHA for 9712df4
prog.10.3.c
@@ -0,0 +1,36 @@
1
+#include <stdio.h>
2
+
3
+int main (void)
4
+{
5
+ void concat (char result[], const char str1[], const char str2[]);
6
+ const char s1[] = { "Test " };
7
+ const char s2[] = { "works." };
8
+ char s3[20];
9
10
+ concat (s3, s1, s2);
11
12
+ printf ("%s\n", s3);
13
14
+ return 0;
15
+}
16
17
+// Function to concatenate two character strings
18
19
+void concat (char result[], const char str1[], const char str2[])
20
21
+ int i, j;
22
23
+ // copy str1 to result
24
25
+ for ( i = 0; str1[i] != '\0'; ++i )
26
+ result[i] = str1[i];
27
28
+ // copy str2 to result
29
30
+ for ( j = 0; str2[j] != '\0'; ++j )
31
+ result[i + j] = str2[j];
32
33
+ // Terminate the concated string with a null character
34
35
+ result [i + j] = '\0';
36
0 commit comments