Skip to content

Instantly share code, notes, and snippets.

@Romain-P
Last active June 14, 2017 04:28
Show Gist options
  • Select an option

  • Save Romain-P/33e8e28bdc603fe19d6dddd200d2afb1 to your computer and use it in GitHub Desktop.

Select an option

Save Romain-P/33e8e28bdc603fe19d6dddd200d2afb1 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
char *strdupl(char const *str)
{
char *new;
int i;
i = 0;
while (str && str[i] && ++i);
if (!(new = malloc(sizeof(char) * (i + 1))))
return (NULL);
new[i] = 0;
while (--i >= 0)
new[i] = str[i];
return (new);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment