fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int main(void){
  6. char *ptr = malloc(256);
  7. char *tmpPTR = NULL;
  8.  
  9. tmpPTR = malloc (256);
  10. strcpy ( ptr, "Michi");
  11.  
  12. strcpy(tmpPTR, ptr);
  13. free(ptr);
  14.  
  15. ptr = malloc(512);
  16.  
  17. strcpy( ptr, tmpPTR );
  18. free( tmpPTR );
  19.  
  20. printf("PTR = %s\n", ptr);
  21. free( ptr );
  22. }
Success #stdin #stdout 0s 2300KB
stdin
Standard input is empty
stdout
PTR = Michi