Advertisement
programmer1997

strdup.c

Jan 7th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.21 KB | None | 0 0
  1. #ifndef STRDUP_H
  2.  
  3. #include <stdlib.h>
  4. #include "strdup.h"
  5.  
  6. #else
  7. char *strdup(const char *str){
  8.     int len = strlen(str) + 1;
  9.     char *buf = malloc(len);
  10.     if(buf) memcpy(buf, str, len);
  11.     return buf;
  12. }
  13. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement