fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void concat
  5. (const char lstr[], const char rstr[], char outstr[])
  6. {
  7. int i, j;
  8.  
  9. i = j = 0;
  10. while (lstr[i] != '\0')
  11. {
  12. outstr[i] = lstr[i];
  13. ++i;
  14. }
  15. while ((outstr[i++] = rstr[j++]) != '\0')
  16. ;
  17. }
  18.  
  19. int main(void)
  20. {
  21. char lword[] = "foo";
  22. char rword[] = "bar";
  23. char outword[strlen(lword) + strlen(rword) + 1];
  24.  
  25. concat(lword, rword, outword);
  26. printf("%s\n", outword);
  27. }
  28.  
Success #stdin #stdout 0s 1832KB
stdin
Standard input is empty
stdout
foobar