Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. char            *my_strdup(char *dest, char *src)
  2. {
  3.   int           i;
  4.   int           c;
  5.   char          *new_way;
  6.  
  7.   i = 0;
  8.   c = 2;
  9.   while (src[i])
  10.     i++;
  11.   if ((new_way = malloc(sizeof(*new_way) * (i + 3))) == NULL)
  12.     return (NULL);
  13.   i = 0;
  14.   new_way[0] = '.';
  15.   new_way[1] = '/';
  16.   while (src[i])
  17.     {
  18.       new_way[c] = src[i];
  19.       c++;
  20.       i++;
  21.     }
  22.   new_way[c] = '\0';
  23.   return (dest);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement