---
title: "c语言获取当前目录"
author: "conjohn668"
date: "2010-09-12T22:20:13Z"
tags: []
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2010-09-12T22:20:13Z"
id: 761636
url: "https://conjohn668.iteye.com/blog/761636"
---

```
#include <stdio.h>
#include <dir.h>

int main(void)
{
   char buffer[MAXPATH];

   getcwd(buffer, MAXPATH);
   printf("The current directory is: %s/n", buffer);
   return 0;
}
```