getcw获取程序目录
获取当前目录及文件名
#includemain() { char buf[80]; getcwd(buf, sizeof(buf)); printf("current working directory : %sn", buf); //调用 malloc 动态给 buf 分配,但要特别注意使用后释放缓冲,防止内存泄漏 char *path = NULL; path = getcwd(NULL,0); puts(path); free(path); //不需考虑缓冲大小 char *path; path = get_current_dir_name(); }



