unix环境高级编程 4-24实例结果出错
#include “apue.h”
#include “path_alloc.h”
int main()
{
char *ptr;
size_t size;
if(chdir("/usr") < 0)
err_sys(“chdir error\n”);
ptr = path_alloc(&size);
if(getcwd(ptr,size) == NULL)
err_sys(“getcwd error\n”);
printf(“cwd = %s\n”,ptr);
exit(0);
}
结果:
getcwd error
: Bad address
出现getcwd error,可以理解,但是第二行是怎么回事?请哪位大神解答一下,谢谢!