fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void my_strcpy(char *dest, const char *src) {
  6. while (*dest++ = *src++);
  7. }
  8.  
  9. int main(void) {
  10. char *str = "Hello, world!";
  11. char *my_str = (char *) malloc(strlen(str) + 1);
  12.  
  13. my_strcpy(my_str, str);
  14. printf("%s\n", my_str);
  15.  
  16. free(my_str);
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
Hello, world!