159. C Program to Concatenate Two Strings using static.
How does this program work?
- This Program is used to concantenate two strings using static.
Here is the code
int main()
{
char str1[100], str2[100], i, j;
printf("Enter first string: \n");
scanf("%s", str1);
printf("Enter second string: \n");
scanf("%s", str2);
// Calculate the length of string s1
// And store it in i
for(i = 0; str1[i] != '\0'; ++i);
for(j = 0; str2[j] != '\0'; ++j, ++i)
{
str1[i] = str2[j];
}
str1[i] = '\0';
printf("concatenation output: %s", str1);
return 0;
}