bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

P067.c (745B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 14 Jan 2026
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Write a program using function which concatenates two string s1 and s2 in to a third string */
      8 
      9 #include <stdio.h>
     10 
     11 void string_concat(char *s3, char s1[], char s2[])
     12 {
     13     int l1, l2, i, j, k;
     14     i = j = k = 0;
     15     l1 = strlen(s1);
     16     l2 = strlen(s2);
     17     s3 = (char *)malloc((l1 + l2 + 1) * sizeof(char));
     18     while (s1[i] != '\0')
     19     {
     20         s3[k++] = s1[i++];
     21     }
     22     while (s2[j] != '\0')
     23     {
     24         s3[k++] = s2[j++];
     25     }
     26     s3[k] = '\0';
     27     puts(s3);
     28 }
     29 
     30 int main()
     31 {
     32     char s1[] = "JAVA";
     33     char s2[] = "PYTHON";
     34     char *s3 = NULL;
     35     string_concat(s3, s1, s2);
     36     return 0;
     37 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror