Another getcwd question...
Posted
by rubenvb
on Stack Overflow
See other posts from Stack Overflow
or by rubenvb
Published on 2010-05-19T21:35:18Z
Indexed on
2010/05/19
21:50 UTC
Read the original article
Hit count: 170
Sorry to keep hammering on this, but I'm trying to learn :). Is this any good? And yes, I care about memory leaks. I can't find a decent way of preallocating the char*, because there simply seems to be no cross-platform way.
const string getcwd()
{
char* a_cwd = getcwd(NULL,0);
string s_cwd(a_cwd);
free(a_cwd);
return s_cwd;
}
© Stack Overflow or respective owner