how to concat two strings manually code example
Example 1: how add strings together
String firstName = "BarackObama";
String lastName = " Care";
System.out.println(firstName + lastName);
String name = firstName + lastName;
System.out.println(name);
System.out.println("BarackObama" + " Care");
Example 2: Write a program to concatenate two strings.
#include <stdio.h>
int main() {
char s1[100] = "programming ", s2[] = "is awesome";
int length, j;
length = 0;
while (s1[length] != '\0') {
++length;
}
for (j = 0; s2[j] != '\0'; ++j, ++length) {
s1[length] = s2[j];
}
s1[length] = '\0';
printf("After concatenation: ");
puts(s1);
return 0;
}