编程基础-----C语言如何获取当前目录和程序目录

用long getcwd(char *buf, unsigned long size);

#include <stdlib.h>
#include <stdio.h>

#define MAXPATH 128

int main()
{
	char buf[MAXPATH];
	getcwd(buf, MAXPATH);
	printf("The current directory is :%s \n", buf);
	exit(0);
}


你可能感兴趣的:(C语言)