更改程序的工作目录

windows:

#if 1
//#ifdef NDEBUG
	char *lpstr1 = (char*)malloc(MAX_PATH);
	GetCurrentDirectory(MAX_PATH, lpstr1);
	printf("%d-%s\n", MAX_PATH, lpstr1);
	(strrchr(lpstr1, '\\'))[0] = 0;
	printf("%d-%s\n", MAX_PATH, lpstr1);
	(strrchr(lpstr1, '\\'))[0] = 0;
	printf("%d-%s\n", MAX_PATH, lpstr1);
	SetCurrentDirectory(lpstr1);
//#endif
#endif

linux:

chdir()

 

你可能感兴趣的:(C++探究)