getcwd
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define MAX 512
int main(int argc, char * argv[])
{
// 方法一
char path[MAX];
path[0] = '/0';
getcwd(path, sizeof(path));
puts(path);
// 方法二
char * buf = NULL;
buf = getcwd(NULL, 0);
puts(buf);
free(buf);
exit(EXIT_SUCCESS);
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281767.html