fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. const char* s1="Hello, ";
  6. const char* s2="World!";
  7.  
  8. size_t len = strlen(s1) + strlen(s2);
  9. size_t size = sizeof(char) * (len + 1);
  10.  
  11. char * buf = malloc(size);
  12.  
  13. strcpy(buf, s1);
  14. strcat(buf, s2);
  15.  
  16. printf("%s\r\n", buf);
  17.  
  18. free(buf);
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 1852KB
stdin
Standard input is empty
stdout
Hello, World!