I have a old program in which some library function is used and i dont have that library.
So I am writing that program using libraries of c++. In that old code some function is there which is called like this
*string = newstrdup(‘Some string goes here’);
the string variable is declared as char **string;
What he may be doing in that function named ‘newstrdup’ ? I tried many things but i dont know what he is doing … Can anyone help
there has to be a reason that they wrote a ‘new’ version of strdup. So there must be a corner case that it handles differently. like perhaps a null string returns an empty string.
litb’s answer is a replacement for strdup, but I would think there is a reason they did what they did.
If you want to use strdup directly, use a define to rename it, rather than write new code.