errno_t _dupenv_s(
char **buffer,
size_t *sizeInBytes,
const char *varname
);
I have several questions regarding this:
- why a pointer to pointer(
**) is required instead of a pointer(*)? - why
sizeInBytesis necessary,isn’t that available bystrlen(buffer)?
No, it’s asking for the address of a character pointer. The method will allocate the necessary space to hold the variable’s value and set the value of your pointer to it, otherwise NULL. Refer to the example code down the page:
http://msdn.microsoft.com/en-us/library/ms175774(v=VS.80).aspx