📝⚡Beginner
Add or Concatenate Two Strings
Join two strings
Concatenate (join) two strings without using the strcat() function.
Program Code
string_concat.c
C
1#include <stdio.h>23int main() {4 char str1[100] = "Hello ";5 char str2[] = "World!";6 7 int i = 0, j = 0;8 9 // Find end of str110 while (str1[i] != '\0') i++;11 12 // Copy str2 to end of str113 while (str2[j] != '\0') {14 str1[i] = str2[j];15 i++;16 j++;17 }18 str1[i] = '\0'; // Null terminate19 20 printf("Concatenated: %s\n", str1);21 return 0;22}Output
Concatenated: Hello World!
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials