-
Notifications
You must be signed in to change notification settings - Fork 1
/
catenation.c
62 lines (50 loc) · 1002 Bytes
/
catenation.c
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// C Program to concatenate
// two strings without using strcat
#include <stdio.h>
int main()
{
// Get the two Strings to be concatenated
char str1[100] = "Geeks", str2[100] = "World";
// Declare a new Strings
// to store the concatenated String
char str3[100];
int i = 0, j = 0;
printf("\nFirst string: %s", str1);
printf("\nSecond string: %s\n", str2);
//Insert the first string in the new string
while (str1[i]!='\0') {
str3[j]=str1[i];
i++;
j++;
/* code */
}
i=0;
while (str2[i]!='\0') {
str3[j]=str2[i];
i++;
j++;
/* code */
}
printf("concatenated string %s",str3);
return 0;
}
// while (str1[i] != '\0') {
// str3[j] = str1[i];
// i++;
// j++;
// }
//
// // Insert the second string in the new string
// i = 0;
// while (str2[i] != '\0') {
// str3[j] = str2[i];
// i++;
// j++;
// }
// str3[j] = '\0';
//
// // Print the concatenated string
// printf("\nConcatenated string: %s", str3);
//
// return 0;
// }