linux下判断路径是否存在(文件夹是否存在)

#include
#include
#include
#include
#include
using namespace std;

int main(void)
{
 char buff[] = "/home/whc/test2/";
 //1 opendir() and closedir
 DIR *dir=NULL;
 dir = opendir(buff);
 if(NULL == dir)
  cout<<"1:文件不存在"<

转载自    http://blog.csdn.net/weihua1984/article/details/5480281


获取当前路径

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "unistd.h"
int main()
{
	char buf[200];

	if(getcwd(buf, sizeof(buf)-1) != NULL)
	{
		printf(buf);
		printf("\n");
	}
	else
	{
		printf("error \n");
	}

	return 0;
}



转载自    http://blog.csdn.net/abcpanpeng/article/details/6440370



你可能感兴趣的:(Linux,C学习)